diff --git a/app/appearance/icons/ant/icon.js b/app/appearance/icons/ant/icon.js index d9d700dca..df54b8bf8 100644 --- a/app/appearance/icons/ant/icon.js +++ b/app/appearance/icons/ant/icon.js @@ -1,5 +1,8 @@ document.body.insertAdjacentHTML('afterBegin', ` + + + diff --git a/app/appearance/icons/ant/icon.json b/app/appearance/icons/ant/icon.json index f90fa6105..e53c58497 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 52d9f0801..0a0ff7cc7 100644 --- a/app/appearance/icons/index.html +++ b/app/appearance/icons/index.html @@ -28,6 +28,12 @@

SiYuan

+
+ + + + iconCloseRound +
diff --git a/app/appearance/icons/material/icon.js b/app/appearance/icons/material/icon.js index c6471ee91..2d0f6d30b 100644 --- a/app/appearance/icons/material/icon.js +++ b/app/appearance/icons/material/icon.js @@ -1,5 +1,8 @@ document.body.insertAdjacentHTML('afterbegin', ` + + + diff --git a/app/appearance/icons/material/icon.json b/app/appearance/icons/material/icon.json index 15629a592..1a8a14c27 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 94960a03c..c69754686 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 adde23eed..af77dfe30 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 80f1580a7..a9f3e75ee 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 6c5ad4081..46e3b65bb 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 92e29fade..b7d48694b 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 7a021efcb..aedb23174 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 85dec1489..d92bafba8 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 ee1f31c76..8b3524cde 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 = '
'; window.siyuan.user.userTitles.forEach((item) => { - userTitlesHTML += `
${item.icon} ${item.name}
`; + userTitlesHTML += `
${item.icon} ${item.name}
`; }); userTitlesHTML += "
"; } diff --git a/app/src/mobile/util/menu.ts b/app/src/mobile/util/menu.ts index fea3bfbfd..32ab38b08 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 = '
'; window.siyuan.user.userTitles.forEach((item) => { - userTitlesHTML += `
${item.icon} ${item.name}
`; + userTitlesHTML += `
${item.icon} ${item.name}
`; }); userTitlesHTML += "
"; } diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts index 3804a3a83..89fdf7dae 100644 --- a/app/src/protyle/header/Background.ts +++ b/app/src/protyle/header/Background.ts @@ -43,7 +43,7 @@ export class Background { ${window.siyuan.languages.confirm}
-
+
@@ -52,7 +52,7 @@ export class Background {
`; - 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 += `
${item}
`; + html += `
${item}
`; }); 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 36f0dda47..988ea7f70 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 82ebe230a..3401a5214 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 += `
${escapeHtml(item.name)}
` + }) + 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?: ()
-
+
+
${escapeHtml(config.hPath)} - + @@ -175,6 +192,9 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
`; + + 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)}`; + searchPathInputElement.innerHTML = `${escapeHtml(config.hPath)}`; 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", `
${criterion.name}
`) }); }); } }).element); - const searchSubMenu: IMenu[] = []; - criteria.data.forEach((item: ISearchOption) => { - searchSubMenu.push({ - label: `
- ${item.name} - - -
`, - 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)}`; + searchPathInputElement.innerHTML = `${escapeHtml(item.hPath)}`; 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() {