This commit is contained in:
Vanessa 2022-12-21 19:59:21 +08:00
parent d61d22d679
commit acfe78a1d2
6 changed files with 113 additions and 75 deletions

View file

@ -8,6 +8,7 @@
"sortByRankAsc": "Relevance ASC",
"saveCriterion": "Save named criterion",
"useCriterion": "Use named criterion",
"removeCriterion": "Remove named criterion",
"group": "Group",
"noGroupBy": "No grouping",
"groupByDoc": "Group by document",

View file

@ -8,6 +8,7 @@
"sortByRankAsc": "Relevancia ASC",
"saveCriterion": "Guardar criterio nombrado",
"useCriterion": "Usar criterio con nombre",
"removeCriterion": "Eliminar criterio nombrado",
"grupo": "Grupo",
"noGroupBy": "Sin agrupar",
"groupByDoc": "Agrupar por documento",

View file

@ -8,6 +8,7 @@
"sortByRankAsc": "ASC de pertinence",
"saveCriterion": "Enregistrer le critère nommé",
"useCriterion": "Utiliser le critère nommé",
"removeCriterion": "Supprimer le critère nommé",
"groupe": "Groupe",
"noGroupBy": "Aucun regroupement",
"groupByDoc": "Regrouper par document",

View file

@ -8,6 +8,7 @@
"sortByRankAsc": "按相關度升序",
"saveCriterion": "保存命名查詢",
"useCriterion": "使用命名查詢",
"removeCriterion": "移除命名查詢",
"group": "分組",
"noGroupBy": "不分組",
"groupByDoc": "按文檔分組",

View file

@ -8,6 +8,7 @@
"sortByRankAsc": "按相关度升序",
"saveCriterion": "保存命名查询",
"useCriterion": "使用命名查询",
"removeCriterion": "移除命名查询",
"group": "分组",
"noGroupBy": "不分组",
"groupByDoc": "按文档分组",

View file

@ -796,81 +796,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
}
return;
}
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
if (dialogElement && dialogElement.getAttribute("data-key") === window.siyuan.config.keymap.general.search.custom) {
// https://github.com/siyuan-note/siyuan/issues/6828
item.hPath = config.hPath;
item.idPath = config.idPath.join(",").split(",");
}
if (config.layout !== item.layout) {
const data = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEKEYS) || "{}");
if (item.layout === 0) {
element.querySelector(".search__layout").classList.remove("search__layout--row");
if (data.row) {
edit.protyle.element.classList.remove("fn__flex-1");
edit.protyle.element.style.height = data.row;
edit.protyle.element.style.width = "";
} else {
edit.protyle.element.classList.add("fn__flex-1");
}
} else {
element.querySelector(".search__layout").classList.add("search__layout--row");
if (data.col) {
edit.protyle.element.style.width = data.col;
edit.protyle.element.classList.remove("fn__flex-1");
edit.protyle.element.style.height = "";
} else {
edit.protyle.element.classList.add("fn__flex-1");
}
}
setPadding(edit.protyle);
}
if (config.hasReplace !== item.hasReplace) {
if (item.hasReplace) {
element.querySelector("#replaceHistoryBtn").parentElement.classList.remove("fn__none");
} else {
element.querySelector("#replaceHistoryBtn").parentElement.classList.add("fn__none");
}
}
if (item.hPath) {
element.querySelector("#searchPathInput").innerHTML = `${item.hPath}<svg class="search__rmpath"><use xlink:href="#iconClose"></use></svg>`;
} else {
element.querySelector("#searchPathInput").innerHTML = "";
}
if (config.group !== item.group) {
if (item.group === 0) {
element.querySelector("#searchExpand").parentElement.classList.add("fn__none");
} else {
element.querySelector("#searchExpand").parentElement.classList.remove("fn__none");
}
}
let includeChild = true;
let enableIncludeChild = false;
item.idPath.forEach(item => {
if (item.endsWith(".sy")) {
includeChild = false;
}
if (item.split("/").length > 1) {
enableIncludeChild = true;
}
});
const searchIncludeElement = element.querySelector("#searchInclude");
if (includeChild) {
searchIncludeElement.classList.remove("b3-button--cancel");
} else {
searchIncludeElement.classList.add("b3-button--cancel");
}
if (enableIncludeChild) {
searchIncludeElement.removeAttribute("disabled");
} else {
searchIncludeElement.setAttribute("disabled", "disabled");
}
(element.querySelector("#searchInput") as HTMLInputElement).value = item.k;
(element.querySelector("#replaceInput") as HTMLInputElement).value = item.r;
Object.assign(config, item);
inputEvent(element, config, undefined, edit);
localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
window.siyuan.menus.menu.remove();
updateConfig(element, item, config, edit);
});
}
});
@ -882,9 +808,116 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
submenu: searchSubMenu
}).element);
}
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.removeCriterion,
click() {
updateConfig(element, {
sort: 0,
group: 0,
layout: 0,
hasReplace: false,
method: 0,
hPath: "",
idPath: [],
k: "",
r: "",
types: {
document: window.siyuan.config.search.document,
heading: window.siyuan.config.search.heading,
list: window.siyuan.config.search.list,
listItem: window.siyuan.config.search.listItem,
codeBlock: window.siyuan.config.search.codeBlock,
htmlBlock: window.siyuan.config.search.htmlBlock,
mathBlock: window.siyuan.config.search.mathBlock,
table: window.siyuan.config.search.table,
blockquote: window.siyuan.config.search.blockquote,
superBlock: window.siyuan.config.search.superBlock,
paragraph: window.siyuan.config.search.paragraph,
}
}, config, edit);
}
}).element);
window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16}, true);
};
const updateConfig = (element: Element, item: ISearchOption, config: ISearchOption, edit: Protyle) => {
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
if (dialogElement && dialogElement.getAttribute("data-key") === window.siyuan.config.keymap.general.search.custom) {
// https://github.com/siyuan-note/siyuan/issues/6828
item.hPath = config.hPath;
item.idPath = config.idPath.join(",").split(",");
}
if (config.layout !== item.layout) {
const data = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEKEYS) || "{}");
if (item.layout === 0) {
element.querySelector(".search__layout").classList.remove("search__layout--row");
if (data.row) {
edit.protyle.element.classList.remove("fn__flex-1");
edit.protyle.element.style.height = data.row;
edit.protyle.element.style.width = "";
} else {
edit.protyle.element.classList.add("fn__flex-1");
}
} else {
element.querySelector(".search__layout").classList.add("search__layout--row");
if (data.col) {
edit.protyle.element.style.width = data.col;
edit.protyle.element.classList.remove("fn__flex-1");
edit.protyle.element.style.height = "";
} else {
edit.protyle.element.classList.add("fn__flex-1");
}
}
setPadding(edit.protyle);
}
if (config.hasReplace !== item.hasReplace) {
if (item.hasReplace) {
element.querySelector("#replaceHistoryBtn").parentElement.classList.remove("fn__none");
} else {
element.querySelector("#replaceHistoryBtn").parentElement.classList.add("fn__none");
}
}
if (item.hPath) {
element.querySelector("#searchPathInput").innerHTML = `${item.hPath}<svg class="search__rmpath"><use xlink:href="#iconClose"></use></svg>`;
} else {
element.querySelector("#searchPathInput").innerHTML = "";
}
if (config.group !== item.group) {
if (item.group === 0) {
element.querySelector("#searchExpand").parentElement.classList.add("fn__none");
} else {
element.querySelector("#searchExpand").parentElement.classList.remove("fn__none");
}
}
let includeChild = true;
let enableIncludeChild = false;
item.idPath.forEach(item => {
if (item.endsWith(".sy")) {
includeChild = false;
}
if (item.split("/").length > 1) {
enableIncludeChild = true;
}
});
const searchIncludeElement = element.querySelector("#searchInclude");
if (includeChild) {
searchIncludeElement.classList.remove("b3-button--cancel");
} else {
searchIncludeElement.classList.add("b3-button--cancel");
}
if (enableIncludeChild) {
searchIncludeElement.removeAttribute("disabled");
} else {
searchIncludeElement.setAttribute("disabled", "disabled");
}
(element.querySelector("#searchInput") as HTMLInputElement).value = item.k;
(element.querySelector("#replaceInput") as HTMLInputElement).value = item.r;
Object.assign(config, item);
inputEvent(element, config, undefined, edit);
localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
window.siyuan.menus.menu.remove();
}
const addConfigFilterMenu = (config: ISearchOption, edit: Protyle, element: Element) => {
const filterDialog = new Dialog({
title: window.siyuan.languages.type,