diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 96bed036e..a7b535638 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -1,4 +1,5 @@
{
+ "group": "Group",
"noGroupBy": "No grouping",
"groupByDoc": "Group by document",
"leftRightLayout": "Left and right layout",
@@ -6,7 +7,6 @@
"keyword": "Keyword",
"searchMethod": "Search Method",
"regex": "Regex",
- "groupBy": "Grouping and Layout",
"keywordsLimit": "Keywords Limit",
"exportAsImage": "Export as image",
"exportBySiYuan": "Export by SiYuan",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index a66795bd1..024441c88 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -1,4 +1,5 @@
{
+ "grupo": "Grupo",
"noGroupBy": "Sin agrupar",
"groupByDoc": "Agrupar por documento",
"leftRightLayout": "Disposición izquierda y derecha",
@@ -6,7 +7,6 @@
"keyword": "Palabra clave",
"searchMethod": "método de búsqueda",
"regex": "Regex",
- "groupBy": "Agrupación y diseño",
"keywordsLimit": "Límite de palabras clave",
"exportAsImage": "Exportar como imagen",
"exportBySiYuan": "Exportar por SiYuan",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index 74518f66b..768d995b0 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -1,4 +1,5 @@
{
+ "groupe": "Groupe",
"noGroupBy": "Aucun regroupement",
"groupByDoc": "Regrouper par document",
"leftRightLayout": "Disposition gauche et droite",
@@ -6,7 +7,6 @@
"keyword": "Mot-clé",
"searchMethod": "méthode de recherche",
"regex": "Regex",
- "groupBy": "Regroupement et mise en page",
"keywordsLimit": "Limite de mots clés",
"exportAsImage": "Exporter en tant qu'image",
"exportBySiYuan": "Exporter par SiYuan",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index f54cf542c..22f21d2de 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -1,4 +1,5 @@
{
+ "group": "分組",
"noGroupBy": "不分組",
"groupByDoc": "按文檔分組",
"leftRightLayout": "左右佈局",
@@ -6,7 +7,6 @@
"keyword": "關鍵字",
"searchMethod":"搜索方式",
"regex":"正則表達式",
- "groupBy": "分組及佈局",
"keywordsLimit": "關鍵字數量限制",
"exportAsImage": "導出為圖片",
"exportBySiYuan": "由思源筆記導出",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index d36bf828e..f3eeee1e9 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1,4 +1,5 @@
{
+ "group": "分组",
"noGroupBy": "不分组",
"groupByDoc": "按文档分组",
"leftRightLayout": "左右布局",
@@ -6,7 +7,6 @@
"keyword": "关键字",
"searchMethod":"搜索方式",
"regex":"正则表达式",
- "groupBy": "分组及布局",
"keywordsLimit": "关键字数量限制",
"exportAsImage": "导出为图片",
"exportBySiYuan": "由思源笔记导出",
diff --git a/app/src/search/spread.ts b/app/src/search/spread.ts
index 8aa187cdc..8bb3fe881 100644
--- a/app/src/search/spread.ts
+++ b/app/src/search/spread.ts
@@ -105,6 +105,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
replaceList: localData.replaceList || [],
group: localData.group || 0,
layout: localData.layout || 0,
+ sort: localData.sort || 0,
types: localData.types
}, dialog.element.querySelector(".b3-dialog__container").lastElementChild, () => {
dialog.destroy();
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index 6e9ff4fa6..8b16671b2 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -68,6 +68,7 @@ export const openGlobalSearch = (text: string, replace: boolean) => {
replaceList: [],
group: localData.group || 0,
layout: localData.layout || 0,
+ sort: localData.sort || 0,
types: localData.types
}
});
@@ -118,8 +119,8 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
-
-
+
+
@@ -321,8 +322,8 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
event.stopPropagation();
event.preventDefault();
break;
- } else if (target.id === "searchGroup") {
- addConfigGroupMenu(config, edit, element);
+ } else if (target.id === "searchMore") {
+ addConfigMoreMenu(config, edit, element);
window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16}, true);
event.stopPropagation();
event.preventDefault();
@@ -552,50 +553,109 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
return edit;
};
-const addConfigGroupMenu = (config: ISearchOption, edit: Protyle, element: Element) => {
+const addConfigMoreMenu = (config: ISearchOption, edit: Protyle, element: Element) => {
window.siyuan.menus.menu.remove();
- window.siyuan.menus.menu.append(new MenuItem({
- label: window.siyuan.languages.noGroupBy,
- current: config.group === 0,
+ const sortMenu = [{
+ label: window.siyuan.languages.type,
+ current: config.sort === 0,
click() {
- element.querySelector("#searchCollapse").parentElement.classList.add("fn__none");
config.group = 0;
inputEvent(element, config, undefined, edit);
}
- }).element);
- window.siyuan.menus.menu.append(new MenuItem({
- label: window.siyuan.languages.groupByDoc,
- current: config.group === 1,
+ }, {
+ label: window.siyuan.languages.createdASC,
+ current: config.sort === 1,
click() {
- element.querySelector("#searchCollapse").parentElement.classList.remove("fn__none");
config.group = 1;
inputEvent(element, config, undefined, edit);
}
- }).element);
- window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
- window.siyuan.menus.menu.append(new MenuItem({
- label: window.siyuan.languages.topBottomLayout,
- current: config.layout === 0,
+ }, {
+ label: window.siyuan.languages.createdDESC,
+ current: config.sort === 2,
click() {
- element.querySelector(".search__layout").classList.remove("search__layout--row");
- setPadding(edit.protyle);
- config.layout = 0;
- if (!element.parentElement.getAttribute("data-id")) {
- localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
- }
+ config.group = 2;
+ inputEvent(element, config, undefined, edit);
}
+ }, {
+ label: window.siyuan.languages.modifiedASC,
+ current: config.sort === 3,
+ click() {
+ config.group = 3;
+ inputEvent(element, config, undefined, edit);
+ }
+ }, {
+ label: window.siyuan.languages.modifiedDESC,
+ current: config.sort === 4,
+ click() {
+ config.group = 4;
+ inputEvent(element, config, undefined, edit);
+ }
+ }]
+ if (config.group === 1) {
+ sortMenu.push({
+ label: window.siyuan.languages.context,
+ current: config.sort === 5,
+ click() {
+ config.sort = 5;
+ inputEvent(element, config, undefined, edit);
+ }
+ })
+ }
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.sort,
+ type: "submenu",
+ submenu: sortMenu,
}).element);
window.siyuan.menus.menu.append(new MenuItem({
- label: window.siyuan.languages.leftRightLayout,
- current: config.layout === 1,
- click() {
- element.querySelector(".search__layout").classList.add("search__layout--row");
- setPadding(edit.protyle);
- config.layout = 1;
- if (!element.parentElement.getAttribute("data-id")) {
- localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
+ label: window.siyuan.languages.group,
+ type: "submenu",
+ submenu: [{
+ label: window.siyuan.languages.noGroupBy,
+ current: config.group === 0,
+ click() {
+ element.querySelector("#searchCollapse").parentElement.classList.add("fn__none");
+ config.group = 0;
+ if (config.sort === 5) {
+ config.sort = 0;
+ }
+ inputEvent(element, config, undefined, edit);
}
- }
+ }, {
+ label: window.siyuan.languages.groupByDoc,
+ current: config.group === 1,
+ click() {
+ element.querySelector("#searchCollapse").parentElement.classList.remove("fn__none");
+ config.group = 1;
+ inputEvent(element, config, undefined, edit);
+ }
+ }]
+ }).element);
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.layout,
+ type: "submenu",
+ submenu: [{
+ label: window.siyuan.languages.topBottomLayout,
+ current: config.layout === 0,
+ click() {
+ element.querySelector(".search__layout").classList.remove("search__layout--row");
+ setPadding(edit.protyle);
+ config.layout = 0;
+ if (!element.parentElement.getAttribute("data-id")) {
+ localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
+ }
+ }
+ }, {
+ label: window.siyuan.languages.leftRightLayout,
+ current: config.layout === 1,
+ click() {
+ element.querySelector(".search__layout").classList.add("search__layout--row");
+ setPadding(edit.protyle);
+ config.layout = 1;
+ if (!element.parentElement.getAttribute("data-id")) {
+ localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
+ }
+ }
+ }]
}).element);
};
@@ -878,6 +938,7 @@ const inputEvent = (element: Element, config: ISearchOption, inputTimeout: numbe
types: config.types,
paths: config.idPath || [],
groupBy: config.group,
+ orderBy: config.sort,
}, (response) => {
onSearch(response.data.blocks, edit, element);
element.querySelector("#searchResult").innerHTML = window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount);
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index cefe7d9a7..fbe8ac034 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -34,6 +34,7 @@ interface Window {
}
interface ISearchOption {
+ sort: number, // 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时)
group: number, // 0:不分组,1:按文档分组
layout: number // 0:上下,1:左右
hasReplace: boolean,