diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 1730d7f6b..29953d76f 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -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",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index 18a5e8677..6630ab2a1 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -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",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index acae91320..bdd9e2dd1 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -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",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index 2647a1da5..4a1ba7568 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -8,6 +8,7 @@
"sortByRankAsc": "按相關度升序",
"saveCriterion": "保存命名查詢",
"useCriterion": "使用命名查詢",
+ "removeCriterion": "移除命名查詢",
"group": "分組",
"noGroupBy": "不分組",
"groupByDoc": "按文檔分組",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index 43f46279c..318df6a34 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -8,6 +8,7 @@
"sortByRankAsc": "按相关度升序",
"saveCriterion": "保存命名查询",
"useCriterion": "使用命名查询",
+ "removeCriterion": "移除命名查询",
"group": "分组",
"noGroupBy": "不分组",
"groupByDoc": "按文档分组",
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index 908157123..a00cd6d30 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -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}`;
- } 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}`;
+ } 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,