mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 01:50:12 +01:00
This commit is contained in:
parent
c6b3083a24
commit
e4a77c955c
2 changed files with 25 additions and 16 deletions
|
|
@ -225,7 +225,7 @@ export const openCardByData = (cardsData: {
|
|||
filterElement.setAttribute("data-id", toPath[0] === "/" ? toNotebook[0] : getDisplayName(toPath[0], true))
|
||||
filterElement.setAttribute("data-cardtype", toPath[0] === "/" ? "notebook" : "doc")
|
||||
fetchNewRound();
|
||||
})
|
||||
}, [], undefined, window.siyuan.languages.specifyPath, true)
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ export const moveToPath = (fromPaths: string[], toNotebook: string, toPath: stri
|
|||
});
|
||||
};
|
||||
|
||||
export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void, paths?: string[], range?: Range, title?: string) => {
|
||||
export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void, paths?: string[], range?: Range, title?: string, flashcard = false) => {
|
||||
const exitDialog = window.siyuan.dialogs.find((item) => {
|
||||
if (item.element.querySelector("#foldList")) {
|
||||
item.destroy();
|
||||
|
|
@ -129,8 +129,9 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
|
|||
}
|
||||
const searchListElement = dialog.element.querySelector("#foldList");
|
||||
const searchTreeElement = dialog.element.querySelector("#foldTree");
|
||||
setNoteBook((notebooks) => {
|
||||
let html = "";
|
||||
window.siyuan.notebooks.forEach((item) => {
|
||||
notebooks.forEach((item) => {
|
||||
if (!item.closed) {
|
||||
html += `<ul class="b3-list b3-list--background">
|
||||
<li class="b3-list-item${html === "" ? " b3-list-item--focus" : ""}" data-path="/" data-box="${item.id}">
|
||||
|
|
@ -143,6 +144,8 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
|
|||
}
|
||||
});
|
||||
searchTreeElement.innerHTML = html;
|
||||
}, flashcard);
|
||||
|
||||
const inputElement = dialog.element.querySelector(".b3-text-field") as HTMLInputElement;
|
||||
inputElement.focus();
|
||||
const inputEvent = (event?: InputEvent) => {
|
||||
|
|
@ -158,7 +161,8 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
|
|||
searchListElement.classList.remove("fn__none");
|
||||
searchListElement.scrollTo(0, 0);
|
||||
fetchPost("/api/filetree/searchDocs", {
|
||||
k: inputElement.value
|
||||
k: inputElement.value,
|
||||
flashcard,
|
||||
}, (data) => {
|
||||
let fileHTML = "";
|
||||
data.data.forEach((item: { boxIcon: string, box: string, hPath: string, path: string }) => {
|
||||
|
|
@ -198,7 +202,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
|
|||
if (searchListElement.classList.contains("fn__none")) {
|
||||
if ((event.key === "ArrowRight" && !currentItemElement.querySelector(".b3-list-item__arrow--open") && !currentItemElement.querySelector(".b3-list-item__toggle").classList.contains("fn__hidden")) ||
|
||||
(event.key === "ArrowLeft" && currentItemElement.querySelector(".b3-list-item__arrow--open"))) {
|
||||
getLeaf(currentItemElement);
|
||||
getLeaf(currentItemElement, flashcard);
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
|
@ -340,7 +344,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
|
|||
let target = event.target as HTMLElement;
|
||||
while (target && !target.isEqualNode(dialog.element)) {
|
||||
if (target.classList.contains("b3-list-item__toggle")) {
|
||||
getLeaf(target.parentElement);
|
||||
getLeaf(target.parentElement, flashcard);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
|
|
@ -392,7 +396,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
|
|||
});
|
||||
};
|
||||
|
||||
const getLeaf = (liElement: HTMLElement) => {
|
||||
const getLeaf = (liElement: HTMLElement, flashcard:boolean) => {
|
||||
const toggleElement = liElement.querySelector(".b3-list-item__arrow");
|
||||
if (toggleElement.classList.contains("b3-list-item__arrow--open")) {
|
||||
toggleElement.classList.remove("b3-list-item__arrow--open");
|
||||
|
|
@ -412,6 +416,7 @@ const getLeaf = (liElement: HTMLElement) => {
|
|||
notebook: notebookId,
|
||||
path: liElement.getAttribute("data-path"),
|
||||
sort: window.siyuan.config.fileTree.sort,
|
||||
flashcard,
|
||||
}, response => {
|
||||
if (response.data.path === "/" && response.data.files.length === 0) {
|
||||
showMessage(window.siyuan.languages.emptyContent);
|
||||
|
|
@ -490,9 +495,13 @@ export const getOpenNotebookCount = () => {
|
|||
return count;
|
||||
};
|
||||
|
||||
export const setNoteBook = (cb?: (notebook: INotebook[]) => void) => {
|
||||
fetchPost("/api/notebook/lsNotebooks", {}, (response) => {
|
||||
export const setNoteBook = (cb?: (notebook: INotebook[]) => void, flashcard = false) => {
|
||||
fetchPost("/api/notebook/lsNotebooks", {
|
||||
flashcard
|
||||
}, (response) => {
|
||||
if (!flashcard) {
|
||||
window.siyuan.notebooks = response.data.notebooks;
|
||||
}
|
||||
if (cb) {
|
||||
cb(response.data.notebooks);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue