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-id", toPath[0] === "/" ? toNotebook[0] : getDisplayName(toPath[0], true))
|
||||||
filterElement.setAttribute("data-cardtype", toPath[0] === "/" ? "notebook" : "doc")
|
filterElement.setAttribute("data-cardtype", toPath[0] === "/" ? "notebook" : "doc")
|
||||||
fetchNewRound();
|
fetchNewRound();
|
||||||
})
|
}, [], undefined, window.siyuan.languages.specifyPath, true)
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).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) => {
|
const exitDialog = window.siyuan.dialogs.find((item) => {
|
||||||
if (item.element.querySelector("#foldList")) {
|
if (item.element.querySelector("#foldList")) {
|
||||||
item.destroy();
|
item.destroy();
|
||||||
|
|
@ -129,8 +129,9 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
|
||||||
}
|
}
|
||||||
const searchListElement = dialog.element.querySelector("#foldList");
|
const searchListElement = dialog.element.querySelector("#foldList");
|
||||||
const searchTreeElement = dialog.element.querySelector("#foldTree");
|
const searchTreeElement = dialog.element.querySelector("#foldTree");
|
||||||
|
setNoteBook((notebooks) => {
|
||||||
let html = "";
|
let html = "";
|
||||||
window.siyuan.notebooks.forEach((item) => {
|
notebooks.forEach((item) => {
|
||||||
if (!item.closed) {
|
if (!item.closed) {
|
||||||
html += `<ul class="b3-list b3-list--background">
|
html += `<ul class="b3-list b3-list--background">
|
||||||
<li class="b3-list-item${html === "" ? " b3-list-item--focus" : ""}" data-path="/" data-box="${item.id}">
|
<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;
|
searchTreeElement.innerHTML = html;
|
||||||
|
}, flashcard);
|
||||||
|
|
||||||
const inputElement = dialog.element.querySelector(".b3-text-field") as HTMLInputElement;
|
const inputElement = dialog.element.querySelector(".b3-text-field") as HTMLInputElement;
|
||||||
inputElement.focus();
|
inputElement.focus();
|
||||||
const inputEvent = (event?: InputEvent) => {
|
const inputEvent = (event?: InputEvent) => {
|
||||||
|
|
@ -158,7 +161,8 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
|
||||||
searchListElement.classList.remove("fn__none");
|
searchListElement.classList.remove("fn__none");
|
||||||
searchListElement.scrollTo(0, 0);
|
searchListElement.scrollTo(0, 0);
|
||||||
fetchPost("/api/filetree/searchDocs", {
|
fetchPost("/api/filetree/searchDocs", {
|
||||||
k: inputElement.value
|
k: inputElement.value,
|
||||||
|
flashcard,
|
||||||
}, (data) => {
|
}, (data) => {
|
||||||
let fileHTML = "";
|
let fileHTML = "";
|
||||||
data.data.forEach((item: { boxIcon: string, box: string, hPath: string, path: string }) => {
|
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 (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")) ||
|
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"))) {
|
(event.key === "ArrowLeft" && currentItemElement.querySelector(".b3-list-item__arrow--open"))) {
|
||||||
getLeaf(currentItemElement);
|
getLeaf(currentItemElement, flashcard);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -340,7 +344,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
|
||||||
let target = event.target as HTMLElement;
|
let target = event.target as HTMLElement;
|
||||||
while (target && !target.isEqualNode(dialog.element)) {
|
while (target && !target.isEqualNode(dialog.element)) {
|
||||||
if (target.classList.contains("b3-list-item__toggle")) {
|
if (target.classList.contains("b3-list-item__toggle")) {
|
||||||
getLeaf(target.parentElement);
|
getLeaf(target.parentElement, flashcard);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
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");
|
const toggleElement = liElement.querySelector(".b3-list-item__arrow");
|
||||||
if (toggleElement.classList.contains("b3-list-item__arrow--open")) {
|
if (toggleElement.classList.contains("b3-list-item__arrow--open")) {
|
||||||
toggleElement.classList.remove("b3-list-item__arrow--open");
|
toggleElement.classList.remove("b3-list-item__arrow--open");
|
||||||
|
|
@ -412,6 +416,7 @@ const getLeaf = (liElement: HTMLElement) => {
|
||||||
notebook: notebookId,
|
notebook: notebookId,
|
||||||
path: liElement.getAttribute("data-path"),
|
path: liElement.getAttribute("data-path"),
|
||||||
sort: window.siyuan.config.fileTree.sort,
|
sort: window.siyuan.config.fileTree.sort,
|
||||||
|
flashcard,
|
||||||
}, response => {
|
}, response => {
|
||||||
if (response.data.path === "/" && response.data.files.length === 0) {
|
if (response.data.path === "/" && response.data.files.length === 0) {
|
||||||
showMessage(window.siyuan.languages.emptyContent);
|
showMessage(window.siyuan.languages.emptyContent);
|
||||||
|
|
@ -490,9 +495,13 @@ export const getOpenNotebookCount = () => {
|
||||||
return count;
|
return count;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setNoteBook = (cb?: (notebook: INotebook[]) => void) => {
|
export const setNoteBook = (cb?: (notebook: INotebook[]) => void, flashcard = false) => {
|
||||||
fetchPost("/api/notebook/lsNotebooks", {}, (response) => {
|
fetchPost("/api/notebook/lsNotebooks", {
|
||||||
|
flashcard
|
||||||
|
}, (response) => {
|
||||||
|
if (!flashcard) {
|
||||||
window.siyuan.notebooks = response.data.notebooks;
|
window.siyuan.notebooks = response.data.notebooks;
|
||||||
|
}
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(response.data.notebooks);
|
cb(response.data.notebooks);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue