Vanessa 2022-12-02 22:48:24 +08:00
parent 4c9356985c
commit 67d95f8a78
8 changed files with 102 additions and 39 deletions

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -1,4 +1,5 @@
{
"group": "分組",
"noGroupBy": "不分組",
"groupByDoc": "按文檔分組",
"leftRightLayout": "左右佈局",
@ -6,7 +7,6 @@
"keyword": "關鍵字",
"searchMethod":"搜索方式",
"regex":"正則表達式",
"groupBy": "分組及佈局",
"keywordsLimit": "關鍵字數量限制",
"exportAsImage": "導出為圖片",
"exportBySiYuan": "由思源筆記導出",

View file

@ -1,4 +1,5 @@
{
"group": "分组",
"noGroupBy": "不分组",
"groupByDoc": "按文档分组",
"leftRightLayout": "左右布局",
@ -6,7 +7,6 @@
"keyword": "关键字",
"searchMethod":"搜索方式",
"regex":"正则表达式",
"groupBy": "分组及布局",
"keywordsLimit": "关键字数量限制",
"exportAsImage": "导出为图片",
"exportBySiYuan": "由思源笔记导出",

View file

@ -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();

View file

@ -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?: ()
<svg><use xlink:href="#iconFilter"></use></svg>
</span>
<span class="fn__space"></span>
<span id="searchGroup" aria-label="${window.siyuan.languages.groupBy}" class="block__icon b3-tooltips b3-tooltips__w">
<svg><use xlink:href="#iconFiles"></use></svg>
<span id="searchMore" aria-label="${window.siyuan.languages.more}" class="block__icon b3-tooltips b3-tooltips__w">
<svg><use xlink:href="#iconMore"></use></svg>
</span>
<span class="fn__space"></span>
<span id="searchRefresh" aria-label="${window.siyuan.languages.refresh}" class="${closeCB ? "fn__none " : ""}block__icon b3-tooltips b3-tooltips__w">
@ -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);

View file

@ -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,