This commit is contained in:
Vanessa 2022-11-30 10:36:03 +08:00
parent 621abe6029
commit b1c3ccc9e4
4 changed files with 29 additions and 29 deletions

View file

@ -61,8 +61,8 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
paragraph: window.siyuan.config.search.paragraph,
};
}
let hPath = ""
const idPath: string[] = []
let hPath = "";
const idPath: string[] = [];
if (notebookId) {
hPath = escapeHtml(getNotebookName(notebookId));
idPath.push(notebookId);

View file

@ -199,7 +199,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
item.querySelector(".b3-list-item__arrow").classList.add("b3-list-item__arrow--open");
item.nextElementSibling.classList.remove("fn__none");
}
})
});
event.stopPropagation();
event.preventDefault();
break;
@ -209,23 +209,23 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
item.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open");
item.nextElementSibling.classList.add("fn__none");
}
})
});
event.stopPropagation();
event.preventDefault();
break;
} else if (target.id === "searchPath") {
movePathTo((toPath, toNotebook) => {
fetchPost("/api/filetree/getHPathsByPaths", {paths: toPath}, (response) => {
config.idPath = []
const hPathList: string[] = []
config.idPath = [];
const hPathList: string[] = [];
toPath.forEach((item, index) => {
if (item === "/") {
config.idPath.push(toNotebook[index])
hPathList.push(escapeHtml(getNotebookName(toNotebook[index])))
config.idPath.push(toNotebook[index]);
hPathList.push(escapeHtml(getNotebookName(toNotebook[index])));
} else {
config.idPath.push(pathPosix().join(toNotebook[index], item));
}
})
});
if (response.data) {
hPathList.push(...response.data);
}
@ -285,10 +285,10 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
break;
} else if (target.id === "searchFilter") {
window.siyuan.menus.menu.remove();
let includeChild = true
let includeChild = true;
config.idPath.find(item => {
if (!item.endsWith(".sy")) {
includeChild = false
includeChild = false;
return true;
}
});
@ -555,12 +555,12 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
};
const addConfigGroupMenu = (config: ISearchOption, edit: Protyle, element: Element) => {
window.siyuan.menus.menu.remove()
window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.list1,
current: config.group === 0,
click() {
element.querySelector("#searchCollapse").parentElement.classList.add("fn__none")
element.querySelector("#searchCollapse").parentElement.classList.add("fn__none");
config.group = 0;
inputEvent(element, config, undefined, edit);
}
@ -569,7 +569,7 @@ const addConfigGroupMenu = (config: ISearchOption, edit: Protyle, element: Eleme
label: window.siyuan.languages.doc,
current: config.group === 1,
click() {
element.querySelector("#searchCollapse").parentElement.classList.remove("fn__none")
element.querySelector("#searchCollapse").parentElement.classList.remove("fn__none");
config.group = 1;
inputEvent(element, config, undefined, edit);
}
@ -579,7 +579,7 @@ const addConfigGroupMenu = (config: ISearchOption, edit: Protyle, element: Eleme
current: config.layout === 0,
click() {
element.querySelector("#searchList").parentElement.style.flexDirection = "column";
setPadding(edit.protyle)
setPadding(edit.protyle);
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
@ -587,7 +587,7 @@ const addConfigGroupMenu = (config: ISearchOption, edit: Protyle, element: Eleme
current: config.layout === 1,
click() {
element.querySelector("#searchList").parentElement.style.flexDirection = "row";
setPadding(edit.protyle)
setPadding(edit.protyle);
}
}).element);
};

View file

@ -941,7 +941,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
}
if (isFile && matchHotKey(window.siyuan.config.keymap.general.move.custom, event)) {
window.siyuan.menus.menu.remove();
const pathes = getTopPaths(liElements)
const pathes = getTopPaths(liElements);
movePathTo((toPath, toNotebook) => {
moveToPath(pathes, toNotebook[0], toPath[0]);
}, pathes);

View file

@ -186,9 +186,9 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
if (event.key.startsWith("Arrow")) {
currentItemElements.forEach((item, index) => {
if (index !== 0) {
item.classList.remove("b3-list-item--focus")
item.classList.remove("b3-list-item--focus");
}
})
});
}
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")) ||
@ -320,12 +320,12 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
if (currentItemElements.length === 0) {
return;
}
const pathList: string[] = []
const notebookIdList: string[] = []
const pathList: string[] = [];
const notebookIdList: string[] = [];
currentItemElements.forEach(item => {
pathList.push(item.getAttribute("data-path"))
notebookIdList.push(item.getAttribute("data-box"))
})
pathList.push(item.getAttribute("data-path"));
notebookIdList.push(item.getAttribute("data-box"));
});
cb(pathList, notebookIdList);
dialog.destroy();
event.preventDefault();
@ -345,12 +345,12 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
if (currentItemElements.length === 0) {
return;
}
const pathList: string[] = []
const notebookIdList: string[] = []
const pathList: string[] = [];
const notebookIdList: string[] = [];
currentItemElements.forEach(item => {
pathList.push(item.getAttribute("data-path"))
notebookIdList.push(item.getAttribute("data-box"))
})
pathList.push(item.getAttribute("data-path"));
notebookIdList.push(item.getAttribute("data-box"));
});
cb(pathList, notebookIdList);
dialog.destroy();
event.preventDefault();