Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/7751

Vanessae56de82983fe
diff --git a/app/appearance/icons/ant/icon.js b/app/appearance/icons/ant/icon.js
index d9d700dca1..df54b8bf8b 100644
--- a/app/appearance/icons/ant/icon.js
+++ b/app/appearance/icons/ant/icon.js
@@ -1,5 +1,8 @@
document.body.insertAdjacentHTML('afterBegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
<defs>
+ <symbol id="iconCloseRound" viewBox="0 0 32 32">
+ <path d="M16 1c-8.295 0-15 6.705-15 15s6.705 15 15 15 15-6.705 15-15-6.705-15-15-15zM23.5 21.385l-2.115 2.115-5.385-5.385-5.385 5.385-2.115-2.115 5.385-5.385-5.385-5.385 2.115-2.115 5.385 5.385 5.385-5.385 2.115 2.115-5.385 5.385 5.385 5.385z"></path>
+ </symbol>
<symbol id="iconLayout" viewBox="0 0 32 32">
<path d="M29.8 1h-27.6c-0.664 0-1.2 0.536-1.2 1.2v27.6c0 0.664 0.536 1.2 1.2 1.2h27.6c0.664 0 1.2-0.536 1.2-1.2v-27.6c0-0.664-0.536-1.2-1.2-1.2zM3.7 3.7h5.1v24.6h-5.1v-24.6zM28.3 28.3h-17.1v-17.1h17.1v17.1zM11.2 8.8v-5.1h17.1v5.1h-17.1z"></path>
</symbol>
diff --git a/app/appearance/icons/ant/icon.json b/app/appearance/icons/ant/icon.json
index f90fa61050..e53c58497f 100644
--- a/app/appearance/icons/ant/icon.json
+++ b/app/appearance/icons/ant/icon.json
@@ -2,5 +2,5 @@
"name": "ant",
"author": "Vanessa",
"url": "https://github.com/Vanessa219",
- "version": "1.16.1"
+ "version": "1.17.0"
}
diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html
index 52d9f08013..0a0ff7cc7c 100644
--- a/app/appearance/icons/index.html
+++ b/app/appearance/icons/index.html
@@ -28,6 +28,12 @@
<body>
<h2>SiYuan</h2>
<div class="fn__clear">
+ <div>
+ <svg>
+ <use xlink:href="#iconCloseRound"></use>
+ </svg>
+ iconCloseRound
+ </div>
<div>
<svg>
<use xlink:href="#iconLayout"></use>
diff --git a/app/appearance/icons/material/icon.js b/app/appearance/icons/material/icon.js
index c6471ee914..2d0f6d30b4 100644
--- a/app/appearance/icons/material/icon.js
+++ b/app/appearance/icons/material/icon.js
@@ -1,5 +1,8 @@
document.body.insertAdjacentHTML('afterbegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
<defs>
+ <symbol id="iconCloseRound" viewBox="0 0 32 32">
+ <path d="M16 1c-8.295 0-15 6.705-15 15s6.705 15 15 15 15-6.705 15-15-6.705-15-15-15zM23.5 21.385l-2.115 2.115-5.385-5.385-5.385 5.385-2.115-2.115 5.385-5.385-5.385-5.385 2.115-2.115 5.385 5.385 5.385-5.385 2.115 2.115-5.385 5.385 5.385 5.385z"></path>
+ </symbol>
<symbol id="iconLayout" viewBox="0 0 32 32">
<path d="M3.5 31q-1 0-1.75-0.75t-0.75-1.75v-25q0-1 0.75-1.75t1.75-0.75h25q1 0 1.75 0.75t0.75 1.75v25q0 1-0.75 1.75t-1.75 0.75zM3.5 28.5h11.25v-25h-11.25v25zM17.25 28.5h11.25v-12.542h-11.25zM17.25 13.458h11.25v-9.958h-11.25z"></path>
</symbol>
diff --git a/app/appearance/icons/material/icon.json b/app/appearance/icons/material/icon.json
index 15629a592c..1a8a14c277 100644
--- a/app/appearance/icons/material/icon.json
+++ b/app/appearance/icons/material/icon.json
@@ -2,5 +2,5 @@
"name": "material",
"author": "Vanessa",
"url": "https://github.com/Vanessa219",
- "version": "1.16.1"
+ "version": "1.17.0"
}
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 94960a03c2..c697546867 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -84,7 +84,7 @@
"sortByRankAsc": "Relevance ASC",
"saveCriterion": "Save named criterion",
"useCriterion": "Use named criterion",
- "removeCriterion": "Remove named criterion",
+ "removeCriterion": "Clear query conditions",
"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 adde23eedd..af77dfe304 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -84,7 +84,7 @@
"sortByRankAsc": "Relevancia ASC",
"saveCriterion": "Guardar criterio nombrado",
"useCriterion": "Usar criterio con nombre",
- "removeCriterion": "Eliminar criterio nombrado",
+ "removeCriterion": "Borrar condiciones de consulta",
"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 80f1580a77..a9f3e75eed 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -84,7 +84,7 @@
"sortByRankAsc": "ASC de pertinence",
"saveCriterion": "Enregistrer le critère nommé",
"useCriterion": "Utiliser le critère nommé",
- "removeCriterion": "Supprimer le critère nommé",
+ "removeCriterion": "Effacer les conditions de requête",
"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 6c5ad4081c..46e3b65bbe 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -84,7 +84,7 @@
"sortByRankAsc": "按相關度升序",
"saveCriterion": "保存命名查詢",
"useCriterion": "使用命名查詢",
- "removeCriterion": "移除命名查詢",
+ "removeCriterion": "清空查詢條件",
"group": "分組",
"noGroupBy": "不分組",
"groupByDoc": "按文檔分組",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index 92e29fade0..b7d48694b7 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -84,7 +84,7 @@
"sortByRankAsc": "按相关度升序",
"saveCriterion": "保存命名查询",
"useCriterion": "使用命名查询",
- "removeCriterion": "移除命名查询",
+ "removeCriterion": "清空查询条件",
"group": "分组",
"noGroupBy": "不分组",
"groupByDoc": "按文档分组",
diff --git a/app/src/assets/scss/business/_search.scss b/app/src/assets/scss/business/_search.scss
index 7a021efcb4..aedb231740 100644
--- a/app/src/assets/scss/business/_search.scss
+++ b/app/src/assets/scss/business/_search.scss
@@ -149,20 +149,15 @@
&__rmpath {
position: absolute;
- height: 8px;
- width: 8px;
- padding: 4px;
- border-radius: 10px;
- color: var(--b3-theme-on-surface);
- background-color: var(--b3-theme-surface);
+ height: 18px;
+ width: 16px;
+ opacity: 0.68;
transition: var(--b3-transition);
- top: 1px;
- right: 0px;
+ right: 0;
cursor: pointer;
&:hover {
- color: var(--b3-theme-on-background);
- background-color: var(--b3-theme-background-light);
+ opacity: 1;
}
}
}
diff --git a/app/src/assets/scss/component/_chip.scss b/app/src/assets/scss/component/_chip.scss
index 85dec1489a..d92bafba87 100644
--- a/app/src/assets/scss/component/_chip.scss
+++ b/app/src/assets/scss/component/_chip.scss
@@ -6,6 +6,7 @@ a.b3-chip:hover {
.b3-chips {
display: flex;
padding: 4px;
+ flex-wrap: wrap;
.b3-chip {
margin: 4px;
@@ -25,6 +26,7 @@ a.b3-chip:hover {
border-radius: 16px;
transition: var(--b3-transition);
+
&--small {
padding: 0 8px;
font-size: 12px;
@@ -41,10 +43,68 @@ a.b3-chip:hover {
color: var(--b3-theme-on-primary);
}
- svg {
+ &--info {
+ color: var(--b3-card-info-color);
+ background-color: var(--b3-card-info-background);
+ }
+
+ &--warning {
+ color: var(--b3-card-warning-color);
+ background-color: var(--b3-card-warning-background);
+ }
+
+ &--error {
+ color: var(--b3-card-error-color);
+ background-color: var(--b3-card-error-background);
+ }
+
+ &--success {
+ color: var(--b3-card-success-color);
+ background-color: var(--b3-card-success-background);
+ }
+
+ &--pointer {
+ cursor: pointer;
+ opacity: .86;
+
+ &:hover {
+ opacity: 1;
+ }
+ }
+
+ svg:not(.b3-chip__close) {
margin-right: 6px;
margin-left: -5px;
height: 16px;
width: 16px;
}
+
+ &__close {
+ margin-right: -5px;
+ margin-left: 6px;
+ border-radius: 10px;
+ height: 16px;
+ width: 16px;
+ transition: var(--b3-transition);
+ cursor: pointer;
+ opacity: .38;
+
+ &:hover {
+ opacity: 1;
+ }
+ }
+
+ &--middle {
+ padding: 4px 6px;
+
+ .b3-chip__close {
+ margin-right: -2px;
+ margin-left: 3px;
+ }
+
+ svg:not(.b3-chip__close) {
+ margin-right: 3px;
+ margin-left: -2px;
+ }
+ }
}
diff --git a/app/src/config/account.ts b/app/src/config/account.ts
index ee1f31c76c..8b3524cde4 100644
--- a/app/src/config/account.ts
+++ b/app/src/config/account.ts
@@ -47,7 +47,7 @@ ${window.siyuan.languages.account2}
if (window.siyuan.user.userTitles.length > 0) {
userTitlesHTML = '<div class="b3-chips" style="position: absolute">';
window.siyuan.user.userTitles.forEach((item) => {
- userTitlesHTML += `<div class="b3-chip">${item.icon} ${item.name}</div>`;
+ userTitlesHTML += `<div class="b3-chip b3-chip--middle">${item.icon} ${item.name}</div>`;
});
userTitlesHTML += "</div>";
}
diff --git a/app/src/mobile/util/menu.ts b/app/src/mobile/util/menu.ts
index fea3bfbfd9..32ab38b08b 100644
--- a/app/src/mobile/util/menu.ts
+++ b/app/src/mobile/util/menu.ts
@@ -23,7 +23,7 @@ const showAccountInfo = (modelElement: HTMLElement, modelMainElement: Element) =
if (window.siyuan.user.userTitles.length > 0) {
userTitlesHTML = '<div class="b3-chips" style="position: absolute">';
window.siyuan.user.userTitles.forEach((item) => {
- userTitlesHTML += `<div class="b3-chip">${item.icon} ${item.name}</div>`;
+ userTitlesHTML += `<div class="b3-chip b3-chip--middle">${item.icon} ${item.name}</div>`;
});
userTitlesHTML += "</div>";
}
diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts
index 3804a3a83a..89fdf7dae4 100644
--- a/app/src/protyle/header/Background.ts
+++ b/app/src/protyle/header/Background.ts
@@ -43,7 +43,7 @@ export class Background {
<span class="protyle-icon protyle-icon--last" data-type="confirm">${window.siyuan.languages.confirm}</span>
</div>
</div>
-<div class="protyle-background__tags"></div>
+<div class="b3-chips"></div>
<div class="protyle-background__iconw">
<div class="protyle-background__icon" data-menu="true" data-type="open-emoji"></div>
<div class="protyle-icons fn__flex-center">
@@ -52,7 +52,7 @@ export class Background {
<span class="protyle-icon protyle-icon--last b3-tooltips b3-tooltips__s" data-type="random" aria-label="${window.siyuan.languages.titleBg}"><svg><use xlink:href="#iconImage"></use></svg></span>
</div>
</div>`;
- this.tagsElement = this.element.querySelector(".protyle-background__tags") as HTMLElement;
+ this.tagsElement = this.element.querySelector(".b3-chips") as HTMLElement;
this.iconElement = this.element.querySelector(".protyle-background__icon") as HTMLElement;
this.imgElement = this.element.firstElementChild.firstElementChild as HTMLImageElement;
if (isMobile()) {
@@ -108,7 +108,9 @@ export class Background {
};
});
}
- this.element.querySelector("input").addEventListener("change", (event: InputEvent & { target: HTMLInputElement }) => {
+ this.element.querySelector("input").addEventListener("change", (event: InputEvent & {
+ target: HTMLInputElement
+ }) => {
if (event.target.files.length === 0) {
return;
}
@@ -351,8 +353,9 @@ export class Background {
this.element.setAttribute("data-node-id", rootId);
if (tags) {
let html = "";
+ const colors = ['secondary', "primary", "info", "success", "warning", "error", ""];
tags.split(",").forEach((item, index) => {
- html += `<div class="item item--${index % 4}" data-type="open-search">${item}<svg data-type="remove-tag"><use xlink:href="#iconClose"></use></svg></div>`;
+ html += `<div class="b3-chip b3-chip--middle b3-chip--pointer b3-chip--${colors[index % 7]}" data-type="open-search">${item}<svg class="b3-chip__close" data-type="remove-tag"><use xlink:href="#iconCloseRound"></use></svg></div>`;
});
this.tagsElement.innerHTML = html;
} else {
@@ -465,7 +468,7 @@ export class Background {
private getTags() {
const tags: string[] = [];
- this.tagsElement.querySelectorAll(".item").forEach(item => {
+ this.tagsElement.querySelectorAll(".b3-chip").forEach(item => {
tags.push(item.textContent.trim());
});
return tags;
diff --git a/app/src/search/spread.ts b/app/src/search/spread.ts
index 36f0dda478..988ea7f700 100644
--- a/app/src/search/spread.ts
+++ b/app/src/search/spread.ts
@@ -75,7 +75,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
const dialog = new Dialog({
content: "",
width: "80vw",
- height: "80vh",
+ height: "90vh",
destroyCallback: () => {
if (range) {
focusByRange(range);
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index 82ebe230a8..3401a5214e 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -20,6 +20,22 @@ import {Dialog} from "../dialog";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {setStorageVal} from "../protyle/util/compatibility";
+const appendCriteria = (element: HTMLElement, data: ISearchOption[]) => {
+ fetchPost("/api/storage/getCriteria", {}, (response) => {
+ let html = '';
+ response.data.forEach((item: ISearchOption, index: number) => {
+ data.push(item);
+ html += `<div data-type="set-criteria" class="b3-chip b3-chip--middle b3-chip--pointer b3-chip--${['secondary', "primary", "info", "success", "warning", "error", ""][index % 7]}">${escapeHtml(item.name)}<svg class="b3-chip__close" data-type="remove-criteria"><use xlink:href="#iconCloseRound"></use></svg></div>`
+ })
+ element.innerHTML = html;
+ if (html === "") {
+ element.classList.add("fn__none")
+ } else {
+ element.classList.remove("fn__none")
+ }
+ });
+}
+
const saveKeyList = (type: "keys" | "replaceKeys", value: string) => {
let list: string[] = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS][type];
list.splice(0, 0, value);
@@ -143,13 +159,14 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
<div class="fn__space"></div>
<div id="replaceHistoryList" data-close="false" class="fn__none b3-menu b3-list b3-list--background"></div>
</div>
- <div class="fn__flex search__header" style="padding: 4px 8px;">
+ <div id="criteria" class="b3-chips" style="background-color: var(--b3-theme-background)"></div>
+ <div class="search__header" style="padding: 4px 8px;">
<span id="searchResult" class="search__result"></span>
<span class="fn__space"></span>
<span class="fn__flex-1"></span>
<span id="searchPathInput" class="search__path ft__on-surface fn__flex-center ft__smaller fn__ellipsis" title="${escapeAttr(config.hPath)}">
${escapeHtml(config.hPath)}
- <svg class="search__rmpath${config.hPath ? "" : " fn__none"}"><use xlink:href="#iconClose"></use></svg>
+ <svg class="search__rmpath${config.hPath ? "" : " fn__none"}"><use xlink:href="#iconCloseRound"></use></svg>
</span>
<span class="fn__space"></span>
<button ${enableIncludeChild ? "" : "disabled"} id="searchInclude" class="b3-button b3-button--small${includeChild ? "" : " b3-button--cancel"}">${window.siyuan.languages.includeChildDoc}</button>
@@ -175,6 +192,9 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
</div>
</div>
<div class="fn__loading fn__loading--top"><img width="120px" src="/stage/loading-pure.svg"></div>`;
+
+ const criteriaData: ISearchOption[] = []
+ appendCriteria(element.querySelector("#criteria"), criteriaData);
const searchPanelElement = element.querySelector("#searchList");
const searchInputElement = element.querySelector("#searchInput") as HTMLInputElement;
const replaceInputElement = element.querySelector("#replaceInput") as HTMLInputElement;
@@ -266,7 +286,36 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
let target = event.target as HTMLElement;
const searchPathInputElement = element.querySelector("#searchPathInput");
while (target && !target.isSameNode(element)) {
- if (target.classList.contains("search__rmpath")) {
+ if (target.classList.contains("b3-chip") && target.getAttribute("data-type") === "set-criteria") {
+ config.removed = false;
+ criteriaData.find(item => {
+ if (item.name === target.innerText.trim()) {
+ updateConfig(element, item, config, edit);
+ return true;
+ }
+ })
+ event.stopPropagation();
+ event.preventDefault();
+ break;
+ } else if (target.classList.contains("b3-chip__close") && target.getAttribute("data-type") === "remove-criteria") {
+ const name = target.parentElement.innerText.trim()
+ fetchPost("/api/storage/removeCriterion", {name});
+ criteriaData.find((item, index) => {
+ if (item.name === name) {
+ criteriaData.splice(index, 1);
+ return true;
+ }
+ })
+ if (target.parentElement.parentElement.childElementCount === 1) {
+ target.parentElement.parentElement.classList.add("fn__none");
+ target.parentElement.remove();
+ } else {
+ target.parentElement.remove();
+ }
+ event.stopPropagation();
+ event.preventDefault();
+ break;
+ } else if (target.classList.contains("search__rmpath")) {
config.idPath = [];
config.hPath = "";
searchPathInputElement.innerHTML = config.hPath;
@@ -317,7 +366,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
hPathList.push(...response.data);
}
config.hPath = hPathList.join(" ");
- searchPathInputElement.innerHTML = `${escapeHtml(config.hPath)}<svg class="search__rmpath"><use xlink:href="#iconClose"></use></svg>`;
+ searchPathInputElement.innerHTML = `${escapeHtml(config.hPath)}<svg class="search__rmpath"><use xlink:href="#iconCloseRound"></use></svg>`;
searchPathInputElement.setAttribute("title", config.hPath);
const includeElement = element.querySelector("#searchInclude");
includeElement.classList.remove("b3-button--cancel");
@@ -371,8 +420,8 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
icon: "iconSearch",
title: window.siyuan.languages.search,
callback(tab) {
- config.k = searchInputElement.value
- config.r = replaceInputElement.value
+ config.k = searchInputElement.value;
+ config.r = replaceInputElement.value;
const asset = new Search({
tab,
config
@@ -394,7 +443,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
event.preventDefault();
break;
} else if (target.id === "searchMore") {
- addConfigMoreMenu(config, edit, element, event);
+ addConfigMoreMenu(config, edit, element, event, criteriaData);
event.stopPropagation();
event.preventDefault();
break;
@@ -633,10 +682,10 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
return edit;
};
-const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element: Element, event: MouseEvent) => {
- const criteria = await fetchSyncPost("/api/storage/getCriteria");
+const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element: Element, event: MouseEvent, criteriaData: ISearchOption[]) => {
window.siyuan.menus.menu.remove();
const sortMenu = [{
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.type,
current: config.sort === 0,
click() {
@@ -644,6 +693,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
inputEvent(element, config, undefined, edit);
}
}, {
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.createdASC,
current: config.sort === 1,
click() {
@@ -651,6 +701,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
inputEvent(element, config, undefined, edit);
}
}, {
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.createdDESC,
current: config.sort === 2,
click() {
@@ -658,6 +709,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
inputEvent(element, config, undefined, edit);
}
}, {
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.modifiedASC,
current: config.sort === 3,
click() {
@@ -665,6 +717,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
inputEvent(element, config, undefined, edit);
}
}, {
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.modifiedDESC,
current: config.sort === 4,
click() {
@@ -672,6 +725,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
inputEvent(element, config, undefined, edit);
}
}, {
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.sortByRankAsc,
current: config.sort === 6,
click() {
@@ -679,6 +733,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
inputEvent(element, config, undefined, edit);
}
}, {
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.sortByRankDesc,
current: config.sort === 7,
click() {
@@ -688,6 +743,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
}];
if (config.group === 1) {
sortMenu.push({
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.sortByContent,
current: config.sort === 5,
click() {
@@ -697,14 +753,17 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
});
}
window.siyuan.menus.menu.append(new MenuItem({
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.sort,
type: "submenu",
submenu: sortMenu,
}).element);
window.siyuan.menus.menu.append(new MenuItem({
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.group,
type: "submenu",
submenu: [{
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.noGroupBy,
current: config.group === 0,
click() {
@@ -716,6 +775,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
inputEvent(element, config, undefined, edit);
}
}, {
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.groupByDoc,
current: config.group === 1,
click() {
@@ -728,9 +788,11 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
const isPopover = hasClosestByClassName(element, "b3-dialog__container");
window.siyuan.menus.menu.append(new MenuItem({
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.layout,
type: "submenu",
submenu: [{
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.topBottomLayout,
current: isPopover ? localData.layout === 0 : localData.layoutTab === 0,
click() {
@@ -751,6 +813,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
setStorageVal(Constants.LOCAL_SEARCHKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]);
}
}, {
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.leftRightLayout,
current: isPopover ? localData.layout === 1 : localData.layoutTab === 1,
click() {
@@ -775,6 +838,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.saveCriterion,
+ iconHTML: Constants.ZWSP,
click() {
const saveDialog = new Dialog({
title: window.siyuan.languages.saveCriterion,
@@ -804,47 +868,18 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
config.r = (element.querySelector("#replaceInput") as HTMLInputElement).value;
const criterion = config;
criterion.name = value;
+ criteriaData.push(Object.assign({}, criterion));
fetchPost("/api/storage/setCriterion", {criterion}, () => {
saveDialog.destroy();
+ const criteriaElement = element.querySelector("#criteria")
+ criteriaElement.classList.remove("fn__none");
+ criteriaElement.insertAdjacentHTML("beforeend", `<div data-type="set-criteria" class="b3-chip b3-chip--middle b3-chip--pointer b3-chip--${['secondary', "primary", "info", "success", "warning", "error", ""][(criteriaElement.childElementCount) % 7]}">${criterion.name}<svg class="b3-chip__close" data-type="remove-criteria"><use xlink:href="#iconCloseRound"></use></svg></div>`)
});
});
}
}).element);
- const searchSubMenu: IMenu[] = [];
- criteria.data.forEach((item: ISearchOption) => {
- searchSubMenu.push({
- label: `<div class="fn__flex">
- <span class="fn__flex-1">${item.name}</span>
- <span class="fn__space"></span>
- <svg class="b3-menu__icon fn__a" style="width: 8px"><use xlink:href="#iconClose"></use></svg>
-</div>`,
- bind(menuElement) {
- menuElement.addEventListener("click", (event) => {
- if (hasClosestByClassName(event.target as HTMLElement, "fn__a")) {
- fetchPost("/api/storage/removeCriterion", {name: item.name.trim()});
- event.preventDefault();
- event.stopPropagation();
- if (!menuElement.previousElementSibling && !menuElement.nextElementSibling) {
- menuElement.parentElement.parentElement.remove();
- } else {
- menuElement.remove();
- }
- return;
- }
- config.removed = false;
- updateConfig(element, item, config, edit);
- });
- }
- });
- });
- if (searchSubMenu.length > 0) {
- window.siyuan.menus.menu.append(new MenuItem({
- label: window.siyuan.languages.useCriterion,
- type: "submenu",
- submenu: searchSubMenu
- }).element);
- }
window.siyuan.menus.menu.append(new MenuItem({
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.removeCriterion,
click() {
updateConfig(element, {
@@ -893,7 +928,7 @@ const updateConfig = (element: Element, item: ISearchOption, config: ISearchOpti
}
const searchPathInputElement = element.querySelector("#searchPathInput")
if (item.hPath) {
- searchPathInputElement.innerHTML = `${escapeHtml(item.hPath)}<svg class="search__rmpath"><use xlink:href="#iconClose"></use></svg>`;
+ searchPathInputElement.innerHTML = `${escapeHtml(item.hPath)}<svg class="search__rmpath"><use xlink:href="#iconCloseRound"></use></svg>`;
searchPathInputElement.setAttribute("title", item.hPath);
} else {
searchPathInputElement.innerHTML = "";
@@ -1087,6 +1122,7 @@ const addConfigFilterMenu = (config: ISearchOption, edit: Protyle, element: Elem
const addQueryMenu = (config: ISearchOption, edit: Protyle, element: Element) => {
const searchSyntaxCheckElement = element.querySelector("#searchSyntaxCheck");
window.siyuan.menus.menu.append(new MenuItem({
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.keyword,
current: config.method === 0,
click() {
@@ -1096,6 +1132,7 @@ const addQueryMenu = (config: ISearchOption, edit: Protyle, element: Element) =>
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.querySyntax,
current: config.method === 1,
click() {
@@ -1105,6 +1142,7 @@ const addQueryMenu = (config: ISearchOption, edit: Protyle, element: Element) =>
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
+ iconHTML: Constants.ZWSP,
label: "SQL",
current: config.method === 2,
click() {
@@ -1114,6 +1152,7 @@ const addQueryMenu = (config: ISearchOption, edit: Protyle, element: Element) =>
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
+ iconHTML: Constants.ZWSP,
label: window.siyuan.languages.regex,
current: config.method === 3,
click() {