mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 08:00:13 +01:00
🚨
This commit is contained in:
parent
bc3ab68a9d
commit
be3ac44ce7
12 changed files with 80 additions and 85 deletions
|
|
@ -33,7 +33,7 @@ export const deleteFiles = (liElements: Element[]) => {
|
|||
if (liElements.length === 1) {
|
||||
const itemTopULElement = hasTopClosestByTag(liElements[0], "UL");
|
||||
if (itemTopULElement) {
|
||||
const itemNotebookId = itemTopULElement.getAttribute("data-url")
|
||||
const itemNotebookId = itemTopULElement.getAttribute("data-url");
|
||||
if (liElements[0].getAttribute("data-type") === "navigation-file") {
|
||||
deleteFile(itemNotebookId, liElements[0].getAttribute("data-path"), getDisplayName(liElements[0].getAttribute("data-name"), false, true));
|
||||
} else {
|
||||
|
|
@ -47,13 +47,13 @@ export const deleteFiles = (liElements: Element[]) => {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
const paths: string[] = []
|
||||
const paths: string[] = [];
|
||||
liElements.forEach(item => {
|
||||
const dataPath = item.getAttribute("data-path")
|
||||
const dataPath = item.getAttribute("data-path");
|
||||
if (dataPath !== "/") {
|
||||
paths.push(item.getAttribute("data-path"));
|
||||
}
|
||||
})
|
||||
});
|
||||
if (paths.length === 0) {
|
||||
showMessage(window.siyuan.languages.notBatchRemove);
|
||||
return;
|
||||
|
|
@ -65,4 +65,4 @@ export const deleteFiles = (liElements: Element[]) => {
|
|||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ export class Wnd {
|
|||
|
||||
private renderTabList(event: MouseEvent) {
|
||||
window.siyuan.menus.menu.remove();
|
||||
window.siyuan.menus.menu.element.classList.add("b3-menu--list")
|
||||
window.siyuan.menus.menu.element.classList.add("b3-menu--list");
|
||||
Array.from(this.headersElement.children).forEach((item: HTMLElement) => {
|
||||
const iconElement = item.querySelector(".item__icon");
|
||||
const graphicElement = item.querySelector(".item__graphic");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import {Tab} from "../Tab";
|
||||
import {Model} from "../Model";
|
||||
import {getDisplayName} from "../../util/pathName";
|
||||
import {Tree} from "../../util/Tree";
|
||||
import {getDockByType, setPanelFocus} from "../util";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
|
|
|
|||
|
|
@ -282,34 +282,34 @@ export class Files extends Model {
|
|||
window.getSelection().removeAllRanges();
|
||||
const liElement = hasClosestByTag(event.target, "LI");
|
||||
if (liElement) {
|
||||
let selectElements: Element[] = Array.from(this.element.querySelectorAll(".b3-list-item--focus"))
|
||||
let selectElements: Element[] = Array.from(this.element.querySelectorAll(".b3-list-item--focus"));
|
||||
if (!liElement.classList.contains("b3-list-item--focus")) {
|
||||
selectElements.forEach((item) => {
|
||||
item.classList.remove("b3-list-item--focus");
|
||||
})
|
||||
});
|
||||
liElement.classList.add("b3-list-item--focus");
|
||||
selectElements = [liElement];
|
||||
}
|
||||
let ids = ""
|
||||
let ids = "";
|
||||
selectElements.forEach((item: HTMLElement) => {
|
||||
item.style.opacity = "0.1";
|
||||
ids += (item.getAttribute("data-node-id") || "") + ","
|
||||
})
|
||||
ids += (item.getAttribute("data-node-id") || "") + ",";
|
||||
});
|
||||
const img = new Image();
|
||||
// TODO: drag preview
|
||||
img.src = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABklJREFUeNqsmFtwE1UYx/97Tdqkbei91Gk6IFouYjqjBR3aQTstoM40DD4gOIO++sL4pr45+q7iu+OMyJMD1RcZAXGEBxiUm0JrKfQiDoVeSEmv2WSP3znJJpt0d1Mgpz3d3bPJnt/+v8v5TqX9X89HGMNZ6iGGdGOZP9a11Riz3bddm4n4tz991Pg+SthkDmVmoPhE2Q5bLxwruIakRVHiJnMo+9s/SZMULfTW56PRUiuWB8UKjmCrIqNfva+kYPb5vRiYi5/lnuQrsWIOkzyWWixnzjc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u5MW+TaQDpJN9SiuiJA4CkyrZL3fdUrz/E0cG5IRudzZjaFTM2lo5CPOy/2toDhpVDtFhgP/hMK/XV7HKFgAJcGbguLdkY2is8ZhpFeaW1warGKdZKUOW7PU8x9bc2Dyhy5ObtaW3B95A5OX7puuRhe2vRsXtpIUtRaFQZ/zoq10rXEdiiJikFZ5gxUt6GpphpLSwaWyL/qq6vQ+WLbynqO4Kgey6/54QXDvCtaNygr2f49oWFx2cg+anZuXqQNp4Dh/iYUg5tkrDgjf4AnlK0UejDzCDqtlfVrKoVq3588h/szMceX43DyEwjmCMS8qmAtCPjD2LdzO/Z370DDmioBd/Tk75gguMLlyNPHmEsht+IhHnuF3B5VQVO4gyIyKCqMA71daCA/W6Ra7buff3NUTmZm0rOitHfXWFjFXkGUQklGizqDT1NxcFdnVrlTF6877CtTy7FCACcQV9N6po/cOa9sByZUGFTZ8mfrVDi+u7sLW9eH8Xb3K3lq8aOyvuuD+7Rp2kkLqh+MQrVIZ/xoOo8z69q0nVudkFVa2jc2GNCoDFKogNTIrG3hZqiZxCrZdi7ibNenIyFRKK1iZ+vse5S9R4YPI4Wom015mb23pwqvbinLLuq0TcsmVAsqeyzVln5n37GorAZPiFKm0LykYF9vFba1V9GuSYVPV0kxWWzt8lTKZP6SgvH2+r7+h5Ksh/KVMhHtrSSoSrHX1AmKl9tuUNaYXNL/trFUP6+5cmteGqojUkmmU0TnvrWanVJJwZhp/JgOBEoLJm2WeyoIqoKUkkXnUGlBmCcUrzZKCna2f3+/aRoxrlRfTxAvbw0Ks/EuZ0prt1RkV5E2yTEVJW6pVKK/r7fivfbNZeQ4JhnWFFGbTKbyo67Ap6zo5FDUX/tfgAEAQ3WUFGFdgUwAAAAASUVORK5CYII=";
|
||||
event.dataTransfer.setDragImage(img, 10, 10);
|
||||
event.dataTransfer.setData(Constants.SIYUAN_DROP_FILE, ids);
|
||||
event.dataTransfer.dropEffect = "move";
|
||||
const tempEelement = document.createElement("div")
|
||||
const tempEelement = document.createElement("div");
|
||||
tempEelement.innerText = ids;
|
||||
window.siyuan.dragElement = tempEelement;
|
||||
}
|
||||
});
|
||||
this.element.addEventListener("dragend", (event: DragEvent & { target: HTMLElement }) => {
|
||||
this.element.addEventListener("dragend", () => {
|
||||
this.element.querySelectorAll(".b3-list-item--focus").forEach((item: HTMLElement) => {
|
||||
item.style.opacity = ""
|
||||
})
|
||||
item.style.opacity = "";
|
||||
});
|
||||
window.siyuan.dragElement = undefined;
|
||||
});
|
||||
this.element.addEventListener("dragover", (event: DragEvent & { target: HTMLElement }) => {
|
||||
|
|
@ -330,13 +330,13 @@ export class Files extends Model {
|
|||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
let sourceOnlyRoot = true
|
||||
let sourceOnlyRoot = true;
|
||||
Array.from(this.element.querySelectorAll(".b3-list-item--focus")).find((item: HTMLElement) => {
|
||||
if (item.getAttribute("data-type") === "navigation-file") {
|
||||
sourceOnlyRoot = false
|
||||
sourceOnlyRoot = false;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
});
|
||||
const targetType = liElement.getAttribute("data-type");
|
||||
if (sourceOnlyRoot && targetType !== "navigation-root") {
|
||||
event.preventDefault();
|
||||
|
|
@ -379,7 +379,7 @@ export class Files extends Model {
|
|||
}
|
||||
const toURL = newUlElement.getAttribute("data-url");
|
||||
const toPath = newElement.getAttribute("data-path");
|
||||
const gutterType = window.siyuan.dragElement?.getAttribute("data-type")
|
||||
const gutterType = window.siyuan.dragElement?.getAttribute("data-type");
|
||||
if (newElement.classList.contains("dragover") && ["NodeListItem", "NodeHeading"].includes(gutterType)) {
|
||||
// 块标拖拽
|
||||
if (gutterType === "NodeHeading") {
|
||||
|
|
@ -406,22 +406,22 @@ export class Files extends Model {
|
|||
newElement.classList.remove("dragover", "dragover__bottom", "dragover__top");
|
||||
return;
|
||||
}
|
||||
const selectRootElements: HTMLElement[] = []
|
||||
const selectFileElements: HTMLElement[] = []
|
||||
const fromPaths: string[] = []
|
||||
const selectRootElements: HTMLElement[] = [];
|
||||
const selectFileElements: HTMLElement[] = [];
|
||||
const fromPaths: string[] = [];
|
||||
this.element.querySelectorAll(".b3-list-item--focus").forEach((item: HTMLElement) => {
|
||||
if (item.getAttribute("data-type") === "navigation-root") {
|
||||
selectRootElements.push(item)
|
||||
selectRootElements.push(item);
|
||||
} else {
|
||||
const dataPath = item.getAttribute("data-path")
|
||||
const dataPath = item.getAttribute("data-path");
|
||||
const isChild = fromPaths.find(item => {
|
||||
if (dataPath.startsWith(item.replace(".sy", ""))) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
});
|
||||
if (!isChild) {
|
||||
selectFileElements.push(item)
|
||||
fromPaths.push(dataPath)
|
||||
selectFileElements.push(item);
|
||||
fromPaths.push(dataPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -437,11 +437,11 @@ export class Files extends Model {
|
|||
if (newElement.classList.contains("dragover__top")) {
|
||||
selectRootElements.forEach(item => {
|
||||
newElement.parentElement.before(item.parentElement);
|
||||
})
|
||||
});
|
||||
} else {
|
||||
selectRootElements.reverse().forEach(item => {
|
||||
newElement.parentElement.after(item.parentElement);
|
||||
})
|
||||
});
|
||||
}
|
||||
const notebooks: string[] = [];
|
||||
Array.from(this.element.children).forEach(item => {
|
||||
|
|
@ -461,7 +461,7 @@ export class Files extends Model {
|
|||
});
|
||||
selectFileElements.forEach(item => {
|
||||
item.setAttribute("data-path", pathPosix().join(toDir, item.getAttribute("data-node-id") + ".sy"));
|
||||
})
|
||||
});
|
||||
hasMove = true;
|
||||
}
|
||||
if (newElement.classList.contains("dragover__top")) {
|
||||
|
|
@ -474,7 +474,7 @@ export class Files extends Model {
|
|||
if (nextULElement) {
|
||||
item.after(nextULElement);
|
||||
}
|
||||
})
|
||||
});
|
||||
} else if (newElement.classList.contains("dragover__bottom")) {
|
||||
selectFileElements.reverse().forEach(item => {
|
||||
let nextULElement;
|
||||
|
|
@ -489,7 +489,7 @@ export class Files extends Model {
|
|||
if (nextULElement) {
|
||||
item.after(nextULElement);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
const paths: string[] = [];
|
||||
Array.from(newElement.parentElement.children).forEach(item => {
|
||||
|
|
@ -668,7 +668,7 @@ export class Files extends Model {
|
|||
targetElement.remove();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
private onMount(data: { data: { box: INotebook, existed?: boolean }, callback?: string }) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import {rename} from "../editor/rename";
|
|||
import {matchHotKey} from "../protyle/util/hotKey";
|
||||
import * as dayjs from "dayjs";
|
||||
import {Constants} from "../constants";
|
||||
import {deleteFile} from "../editor/deleteFile";
|
||||
|
||||
const bindAttrInput = (inputElement: HTMLInputElement, confirmElement: Element) => {
|
||||
inputElement.addEventListener("keydown", (event) => {
|
||||
|
|
@ -266,7 +265,7 @@ export const openFileAttr = (attrs: IObject, id: string, focusName = "bookmark")
|
|||
});
|
||||
}
|
||||
window.siyuan.menus.menu.element.style.zIndex = "310";
|
||||
window.siyuan.menus.menu.element.classList.add("b3-menu--list")
|
||||
window.siyuan.menus.menu.element.classList.add("b3-menu--list");
|
||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY + 16, w: 16});
|
||||
});
|
||||
break;
|
||||
|
|
@ -472,7 +471,7 @@ export const openAttr = (nodeElement: Element, protyle: IProtyle, focusName = "b
|
|||
});
|
||||
}
|
||||
window.siyuan.menus.menu.element.style.zIndex = "310";
|
||||
window.siyuan.menus.menu.element.classList.add("b3-menu--list")
|
||||
window.siyuan.menus.menu.element.classList.add("b3-menu--list");
|
||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY + 16, w: 16});
|
||||
});
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -19,23 +19,22 @@ import {onGetnotebookconf} from "./onGetnotebookconf";
|
|||
import {openSearch} from "../search/spread";
|
||||
import {openFileById} from "../editor/util";
|
||||
/// #endif
|
||||
import {confirmDialog} from "../dialog/confirmDialog";
|
||||
import {Constants} from "../constants";
|
||||
import {newFile} from "../util/newFile";
|
||||
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||
import {deleteFile, deleteFiles} from "../editor/deleteFile";
|
||||
import {deleteFiles} from "../editor/deleteFile";
|
||||
|
||||
export const initNavigationMenu = (liElement: HTMLElement) => {
|
||||
const fileElement = hasClosestByClassName(liElement, "sy__file")
|
||||
const fileElement = hasClosestByClassName(liElement, "sy__file");
|
||||
if (!fileElement) {
|
||||
return;
|
||||
}
|
||||
if (!liElement.classList.contains("b3-list-item--focus")) {
|
||||
fileElement.querySelectorAll(".b3-list-item--focus").forEach(item => {
|
||||
item.classList.remove("b3-list-item--focus");
|
||||
item.removeAttribute("select-end")
|
||||
item.removeAttribute("select-start")
|
||||
})
|
||||
item.removeAttribute("select-end");
|
||||
item.removeAttribute("select-start");
|
||||
});
|
||||
liElement.classList.add("b3-list-item--focus");
|
||||
}
|
||||
const notebookId = liElement.parentElement.getAttribute("data-url");
|
||||
|
|
@ -93,7 +92,7 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
|
|||
label: window.siyuan.languages.delete,
|
||||
accelerator: "⌦",
|
||||
click: () => {
|
||||
deleteFiles(Array.from(fileElement.querySelectorAll(".b3-list-item--focus")))
|
||||
deleteFiles(Array.from(fileElement.querySelectorAll(".b3-list-item--focus")));
|
||||
}
|
||||
}).element);
|
||||
}
|
||||
|
|
@ -143,16 +142,16 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
|
|||
};
|
||||
|
||||
export const initFileMenu = (notebookId: string, pathString: string, liElement: Element) => {
|
||||
const fileElement = hasClosestByClassName(liElement, "sy__file")
|
||||
const fileElement = hasClosestByClassName(liElement, "sy__file");
|
||||
if (!fileElement) {
|
||||
return;
|
||||
}
|
||||
if (!liElement.classList.contains("b3-list-item--focus")) {
|
||||
fileElement.querySelectorAll(".b3-list-item--focus").forEach(item => {
|
||||
item.classList.remove("b3-list-item--focus");
|
||||
item.removeAttribute("select-end")
|
||||
item.removeAttribute("select-start")
|
||||
})
|
||||
item.removeAttribute("select-end");
|
||||
item.removeAttribute("select-start");
|
||||
});
|
||||
liElement.classList.add("b3-list-item--focus");
|
||||
}
|
||||
const id = liElement.getAttribute("data-node-id");
|
||||
|
|
@ -216,7 +215,7 @@ export const initFileMenu = (notebookId: string, pathString: string, liElement:
|
|||
label: window.siyuan.languages.delete,
|
||||
accelerator: "⌦",
|
||||
click: () => {
|
||||
deleteFiles(Array.from(fileElement.querySelectorAll(".b3-list-item--focus")))
|
||||
deleteFiles(Array.from(fileElement.querySelectorAll(".b3-list-item--focus")));
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import {genUUID} from "../../util/genID";
|
|||
import {openMobileFileById} from "../editor";
|
||||
import {unicode2Emoji} from "../../emoji";
|
||||
import {newNotebook} from "../../util/mount";
|
||||
import {setEmpty} from "./setEmpty";
|
||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
||||
import {MenuItem} from "../../menus/Menu";
|
||||
import {newFile} from "../../util/newFile";
|
||||
|
|
@ -525,7 +524,7 @@ export class MobileFiles extends Model {
|
|||
targetElement.remove();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
public onRename(data: { path: string, title: string, box: string }) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import {updatePanelByEditor} from "../editor/util";
|
|||
import {setPanelFocus} from "../layout/util";
|
||||
/// #endif
|
||||
import {Background} from "./header/Background";
|
||||
import {getDisplayName} from "../util/pathName";
|
||||
import {onGet} from "./util/onGet";
|
||||
import {reloadProtyle} from "./util/reload";
|
||||
import {renderBacklink} from "./wysiwyg/renderBacklink";
|
||||
|
|
|
|||
|
|
@ -644,7 +644,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
&& targetElement && !protyle.options.backlinkData) {
|
||||
// 文件树拖拽
|
||||
const scrollTop = protyle.contentElement.scrollTop;
|
||||
const ids = event.dataTransfer.getData(Constants.SIYUAN_DROP_FILE).split(",")
|
||||
const ids = event.dataTransfer.getData(Constants.SIYUAN_DROP_FILE).split(",");
|
||||
for (let i = 0; i < ids.length; i++) {
|
||||
if (ids[i]) {
|
||||
const response = await fetchSyncPost("/api/filetree/doc2Heading", {
|
||||
|
|
|
|||
|
|
@ -184,48 +184,48 @@ export const hasPreviousSibling = (element: Node) => {
|
|||
};
|
||||
|
||||
export const getNextFileLi = (current: Element) => {
|
||||
let nextElement = current.nextElementSibling
|
||||
let nextElement = current.nextElementSibling;
|
||||
if (nextElement) {
|
||||
if (nextElement.tagName === "LI") {
|
||||
return nextElement
|
||||
return nextElement;
|
||||
} else if (nextElement.tagName === "UL") {
|
||||
return nextElement.firstElementChild
|
||||
return nextElement.firstElementChild;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
nextElement = current.parentElement
|
||||
nextElement = current.parentElement;
|
||||
while (nextElement.tagName === "UL") {
|
||||
if (!nextElement.nextElementSibling) {
|
||||
nextElement = nextElement.parentElement
|
||||
nextElement = nextElement.parentElement;
|
||||
} else if (nextElement.nextElementSibling.tagName === "LI") {
|
||||
return nextElement.nextElementSibling
|
||||
return nextElement.nextElementSibling;
|
||||
} else if (nextElement.nextElementSibling.tagName === "UL") {
|
||||
return nextElement.nextElementSibling.firstElementChild;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const getPreviousFileLi = (current: Element) => {
|
||||
let previousElement = current.previousElementSibling
|
||||
let previousElement = current.previousElementSibling;
|
||||
if (previousElement) {
|
||||
if (previousElement.tagName === "LI") {
|
||||
return previousElement
|
||||
return previousElement;
|
||||
} else if (previousElement.tagName === "UL") {
|
||||
return previousElement.lastElementChild
|
||||
return previousElement.lastElementChild;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
previousElement = current.parentElement
|
||||
previousElement = current.parentElement;
|
||||
while (previousElement.tagName === "UL") {
|
||||
if (!previousElement.previousElementSibling) {
|
||||
previousElement = previousElement.parentElement
|
||||
previousElement = previousElement.parentElement;
|
||||
} else if (previousElement.previousElementSibling.tagName === "LI") {
|
||||
return previousElement.previousElementSibling;
|
||||
} else if (previousElement.previousElementSibling.tagName === "UL") {
|
||||
const liElements = previousElement.previousElementSibling.querySelectorAll(".b3-list-item")
|
||||
const liElements = previousElement.previousElementSibling.querySelectorAll(".b3-list-item");
|
||||
return liElements[liElements.length - 1];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -866,7 +866,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
|||
if (!files.element.parentElement.classList.contains("layout__tab--active")) {
|
||||
return false;
|
||||
}
|
||||
const liElements = Array.from(files.element.querySelectorAll(".b3-list-item--focus"))
|
||||
const liElements = Array.from(files.element.querySelectorAll(".b3-list-item--focus"));
|
||||
if (liElements.length === 0) {
|
||||
if (event.key.startsWith("Arrow")) {
|
||||
const liElement = files.element.querySelector(".b3-list-item");
|
||||
|
|
@ -1002,9 +1002,9 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
|||
files.getLeaf(liElements[0], notebookId);
|
||||
liElements.forEach((item, index) => {
|
||||
if (index !== 0) {
|
||||
item.classList.remove("b3-list-item--focus")
|
||||
item.classList.remove("b3-list-item--focus");
|
||||
}
|
||||
})
|
||||
});
|
||||
event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1015,8 +1015,8 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
|||
parentElement = files.element.querySelector(".b3-list-item");
|
||||
}
|
||||
liElements.forEach((item) => {
|
||||
item.classList.remove("b3-list-item--focus")
|
||||
})
|
||||
item.classList.remove("b3-list-item--focus");
|
||||
});
|
||||
parentElement.classList.add("b3-list-item--focus");
|
||||
const parentRect = parentElement.getBoundingClientRect();
|
||||
const fileRect = files.element.getBoundingClientRect();
|
||||
|
|
@ -1047,8 +1047,8 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
|||
}
|
||||
if (nextElement.classList.contains("b3-list-item")) {
|
||||
liElements.forEach((item) => {
|
||||
item.classList.remove("b3-list-item--focus")
|
||||
})
|
||||
item.classList.remove("b3-list-item--focus");
|
||||
});
|
||||
nextElement.classList.add("b3-list-item--focus");
|
||||
const nextRect = nextElement.getBoundingClientRect();
|
||||
const fileRect = files.element.getBoundingClientRect();
|
||||
|
|
@ -1080,8 +1080,8 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
|||
}
|
||||
if (previousElement.classList.contains("b3-list-item")) {
|
||||
liElements.forEach((item) => {
|
||||
item.classList.remove("b3-list-item--focus")
|
||||
})
|
||||
item.classList.remove("b3-list-item--focus");
|
||||
});
|
||||
previousElement.classList.add("b3-list-item--focus");
|
||||
const previousRect = previousElement.getBoundingClientRect();
|
||||
const fileRect = files.element.getBoundingClientRect();
|
||||
|
|
@ -1095,7 +1095,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
|||
}
|
||||
if (event.key === "Delete" || (event.key === "Backspace" && isMac())) {
|
||||
window.siyuan.menus.menu.remove();
|
||||
deleteFiles(liElements)
|
||||
deleteFiles(liElements);
|
||||
return true;
|
||||
}
|
||||
if (event.key === "Enter") {
|
||||
|
|
@ -1109,7 +1109,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
|||
files.getLeaf(item, itemTopULElement.getAttribute("data-url"));
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,22 +60,22 @@ export const pathPosix = () => {
|
|||
};
|
||||
|
||||
export const getTopPaths = (liElements:Element[]) => {
|
||||
const fromPaths:string[] = []
|
||||
const fromPaths:string[] = [];
|
||||
liElements.forEach((item: HTMLElement) => {
|
||||
if (item.getAttribute("data-type") !== "navigation-root") {
|
||||
const dataPath = item.getAttribute("data-path")
|
||||
const dataPath = item.getAttribute("data-path");
|
||||
const isChild = fromPaths.find(item => {
|
||||
if (dataPath.startsWith(item.replace(".sy", ""))) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
});
|
||||
if (!isChild) {
|
||||
fromPaths.push(dataPath)
|
||||
fromPaths.push(dataPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
return fromPaths
|
||||
}
|
||||
return fromPaths;
|
||||
};
|
||||
|
||||
const moveToPath = (fromPaths: string[], toNotebook: string, toPath: string, dialog: Dialog) => {
|
||||
fetchPost("/api/filetree/moveDocs", {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue