mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-16 17:10:53 +08:00
This commit is contained in:
parent
6fc4ba4298
commit
e56de82983
@ -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">
|
document.body.insertAdjacentHTML('afterBegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
|
||||||
<defs>
|
<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">
|
<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>
|
<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>
|
</symbol>
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
"name": "ant",
|
"name": "ant",
|
||||||
"author": "Vanessa",
|
"author": "Vanessa",
|
||||||
"url": "https://github.com/Vanessa219",
|
"url": "https://github.com/Vanessa219",
|
||||||
"version": "1.16.1"
|
"version": "1.17.0"
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,12 @@
|
|||||||
<body>
|
<body>
|
||||||
<h2>SiYuan</h2>
|
<h2>SiYuan</h2>
|
||||||
<div class="fn__clear">
|
<div class="fn__clear">
|
||||||
|
<div>
|
||||||
|
<svg>
|
||||||
|
<use xlink:href="#iconCloseRound"></use>
|
||||||
|
</svg>
|
||||||
|
iconCloseRound
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<svg>
|
<svg>
|
||||||
<use xlink:href="#iconLayout"></use>
|
<use xlink:href="#iconLayout"></use>
|
||||||
|
@ -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">
|
document.body.insertAdjacentHTML('afterbegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
|
||||||
<defs>
|
<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">
|
<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>
|
<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>
|
</symbol>
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
"name": "material",
|
"name": "material",
|
||||||
"author": "Vanessa",
|
"author": "Vanessa",
|
||||||
"url": "https://github.com/Vanessa219",
|
"url": "https://github.com/Vanessa219",
|
||||||
"version": "1.16.1"
|
"version": "1.17.0"
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
"sortByRankAsc": "Relevance ASC",
|
"sortByRankAsc": "Relevance ASC",
|
||||||
"saveCriterion": "Save named criterion",
|
"saveCriterion": "Save named criterion",
|
||||||
"useCriterion": "Use named criterion",
|
"useCriterion": "Use named criterion",
|
||||||
"removeCriterion": "Remove named criterion",
|
"removeCriterion": "Clear query conditions",
|
||||||
"group": "Group",
|
"group": "Group",
|
||||||
"noGroupBy": "No grouping",
|
"noGroupBy": "No grouping",
|
||||||
"groupByDoc": "Group by document",
|
"groupByDoc": "Group by document",
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
"sortByRankAsc": "Relevancia ASC",
|
"sortByRankAsc": "Relevancia ASC",
|
||||||
"saveCriterion": "Guardar criterio nombrado",
|
"saveCriterion": "Guardar criterio nombrado",
|
||||||
"useCriterion": "Usar criterio con nombre",
|
"useCriterion": "Usar criterio con nombre",
|
||||||
"removeCriterion": "Eliminar criterio nombrado",
|
"removeCriterion": "Borrar condiciones de consulta",
|
||||||
"grupo": "Grupo",
|
"grupo": "Grupo",
|
||||||
"noGroupBy": "Sin agrupar",
|
"noGroupBy": "Sin agrupar",
|
||||||
"groupByDoc": "Agrupar por documento",
|
"groupByDoc": "Agrupar por documento",
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
"sortByRankAsc": "ASC de pertinence",
|
"sortByRankAsc": "ASC de pertinence",
|
||||||
"saveCriterion": "Enregistrer le critère nommé",
|
"saveCriterion": "Enregistrer le critère nommé",
|
||||||
"useCriterion": "Utiliser 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",
|
"groupe": "Groupe",
|
||||||
"noGroupBy": "Aucun regroupement",
|
"noGroupBy": "Aucun regroupement",
|
||||||
"groupByDoc": "Regrouper par document",
|
"groupByDoc": "Regrouper par document",
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
"sortByRankAsc": "按相關度升序",
|
"sortByRankAsc": "按相關度升序",
|
||||||
"saveCriterion": "保存命名查詢",
|
"saveCriterion": "保存命名查詢",
|
||||||
"useCriterion": "使用命名查詢",
|
"useCriterion": "使用命名查詢",
|
||||||
"removeCriterion": "移除命名查詢",
|
"removeCriterion": "清空查詢條件",
|
||||||
"group": "分組",
|
"group": "分組",
|
||||||
"noGroupBy": "不分組",
|
"noGroupBy": "不分組",
|
||||||
"groupByDoc": "按文檔分組",
|
"groupByDoc": "按文檔分組",
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
"sortByRankAsc": "按相关度升序",
|
"sortByRankAsc": "按相关度升序",
|
||||||
"saveCriterion": "保存命名查询",
|
"saveCriterion": "保存命名查询",
|
||||||
"useCriterion": "使用命名查询",
|
"useCriterion": "使用命名查询",
|
||||||
"removeCriterion": "移除命名查询",
|
"removeCriterion": "清空查询条件",
|
||||||
"group": "分组",
|
"group": "分组",
|
||||||
"noGroupBy": "不分组",
|
"noGroupBy": "不分组",
|
||||||
"groupByDoc": "按文档分组",
|
"groupByDoc": "按文档分组",
|
||||||
|
@ -149,20 +149,15 @@
|
|||||||
|
|
||||||
&__rmpath {
|
&__rmpath {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 8px;
|
height: 18px;
|
||||||
width: 8px;
|
width: 16px;
|
||||||
padding: 4px;
|
opacity: 0.68;
|
||||||
border-radius: 10px;
|
|
||||||
color: var(--b3-theme-on-surface);
|
|
||||||
background-color: var(--b3-theme-surface);
|
|
||||||
transition: var(--b3-transition);
|
transition: var(--b3-transition);
|
||||||
top: 1px;
|
right: 0;
|
||||||
right: 0px;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: var(--b3-theme-on-background);
|
opacity: 1;
|
||||||
background-color: var(--b3-theme-background-light);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ a.b3-chip:hover {
|
|||||||
.b3-chips {
|
.b3-chips {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
.b3-chip {
|
.b3-chip {
|
||||||
margin: 4px;
|
margin: 4px;
|
||||||
@ -25,6 +26,7 @@ a.b3-chip:hover {
|
|||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
transition: var(--b3-transition);
|
transition: var(--b3-transition);
|
||||||
|
|
||||||
|
|
||||||
&--small {
|
&--small {
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
@ -41,10 +43,68 @@ a.b3-chip:hover {
|
|||||||
color: var(--b3-theme-on-primary);
|
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-right: 6px;
|
||||||
margin-left: -5px;
|
margin-left: -5px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
width: 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ ${window.siyuan.languages.account2}
|
|||||||
if (window.siyuan.user.userTitles.length > 0) {
|
if (window.siyuan.user.userTitles.length > 0) {
|
||||||
userTitlesHTML = '<div class="b3-chips" style="position: absolute">';
|
userTitlesHTML = '<div class="b3-chips" style="position: absolute">';
|
||||||
window.siyuan.user.userTitles.forEach((item) => {
|
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>";
|
userTitlesHTML += "</div>";
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ const showAccountInfo = (modelElement: HTMLElement, modelMainElement: Element) =
|
|||||||
if (window.siyuan.user.userTitles.length > 0) {
|
if (window.siyuan.user.userTitles.length > 0) {
|
||||||
userTitlesHTML = '<div class="b3-chips" style="position: absolute">';
|
userTitlesHTML = '<div class="b3-chips" style="position: absolute">';
|
||||||
window.siyuan.user.userTitles.forEach((item) => {
|
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>";
|
userTitlesHTML += "</div>";
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ export class Background {
|
|||||||
<span class="protyle-icon protyle-icon--last" data-type="confirm">${window.siyuan.languages.confirm}</span>
|
<span class="protyle-icon protyle-icon--last" data-type="confirm">${window.siyuan.languages.confirm}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="protyle-background__tags"></div>
|
<div class="b3-chips"></div>
|
||||||
<div class="protyle-background__iconw">
|
<div class="protyle-background__iconw">
|
||||||
<div class="protyle-background__icon" data-menu="true" data-type="open-emoji"></div>
|
<div class="protyle-background__icon" data-menu="true" data-type="open-emoji"></div>
|
||||||
<div class="protyle-icons fn__flex-center">
|
<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>
|
<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>
|
||||||
</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.iconElement = this.element.querySelector(".protyle-background__icon") as HTMLElement;
|
||||||
this.imgElement = this.element.firstElementChild.firstElementChild as HTMLImageElement;
|
this.imgElement = this.element.firstElementChild.firstElementChild as HTMLImageElement;
|
||||||
if (isMobile()) {
|
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) {
|
if (event.target.files.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -351,8 +353,9 @@ export class Background {
|
|||||||
this.element.setAttribute("data-node-id", rootId);
|
this.element.setAttribute("data-node-id", rootId);
|
||||||
if (tags) {
|
if (tags) {
|
||||||
let html = "";
|
let html = "";
|
||||||
|
const colors = ['secondary', "primary", "info", "success", "warning", "error", ""];
|
||||||
tags.split(",").forEach((item, index) => {
|
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;
|
this.tagsElement.innerHTML = html;
|
||||||
} else {
|
} else {
|
||||||
@ -465,7 +468,7 @@ export class Background {
|
|||||||
|
|
||||||
private getTags() {
|
private getTags() {
|
||||||
const tags: string[] = [];
|
const tags: string[] = [];
|
||||||
this.tagsElement.querySelectorAll(".item").forEach(item => {
|
this.tagsElement.querySelectorAll(".b3-chip").forEach(item => {
|
||||||
tags.push(item.textContent.trim());
|
tags.push(item.textContent.trim());
|
||||||
});
|
});
|
||||||
return tags;
|
return tags;
|
||||||
|
@ -75,7 +75,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
|
|||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
content: "",
|
content: "",
|
||||||
width: "80vw",
|
width: "80vw",
|
||||||
height: "80vh",
|
height: "90vh",
|
||||||
destroyCallback: () => {
|
destroyCallback: () => {
|
||||||
if (range) {
|
if (range) {
|
||||||
focusByRange(range);
|
focusByRange(range);
|
||||||
|
@ -20,6 +20,22 @@ import {Dialog} from "../dialog";
|
|||||||
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||||
import {setStorageVal} from "../protyle/util/compatibility";
|
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) => {
|
const saveKeyList = (type: "keys" | "replaceKeys", value: string) => {
|
||||||
let list: string[] = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS][type];
|
let list: string[] = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS][type];
|
||||||
list.splice(0, 0, value);
|
list.splice(0, 0, value);
|
||||||
@ -143,13 +159,14 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
|||||||
<div class="fn__space"></div>
|
<div class="fn__space"></div>
|
||||||
<div id="replaceHistoryList" data-close="false" class="fn__none b3-menu b3-list b3-list--background"></div>
|
<div id="replaceHistoryList" data-close="false" class="fn__none b3-menu b3-list b3-list--background"></div>
|
||||||
</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 id="searchResult" class="search__result"></span>
|
||||||
<span class="fn__space"></span>
|
<span class="fn__space"></span>
|
||||||
<span class="fn__flex-1"></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)}">
|
<span id="searchPathInput" class="search__path ft__on-surface fn__flex-center ft__smaller fn__ellipsis" title="${escapeAttr(config.hPath)}">
|
||||||
${escapeHtml(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>
|
||||||
<span class="fn__space"></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>
|
<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>
|
</div>
|
||||||
<div class="fn__loading fn__loading--top"><img width="120px" src="/stage/loading-pure.svg"></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 searchPanelElement = element.querySelector("#searchList");
|
||||||
const searchInputElement = element.querySelector("#searchInput") as HTMLInputElement;
|
const searchInputElement = element.querySelector("#searchInput") as HTMLInputElement;
|
||||||
const replaceInputElement = element.querySelector("#replaceInput") 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;
|
let target = event.target as HTMLElement;
|
||||||
const searchPathInputElement = element.querySelector("#searchPathInput");
|
const searchPathInputElement = element.querySelector("#searchPathInput");
|
||||||
while (target && !target.isSameNode(element)) {
|
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.idPath = [];
|
||||||
config.hPath = "";
|
config.hPath = "";
|
||||||
searchPathInputElement.innerHTML = config.hPath;
|
searchPathInputElement.innerHTML = config.hPath;
|
||||||
@ -317,7 +366,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
|||||||
hPathList.push(...response.data);
|
hPathList.push(...response.data);
|
||||||
}
|
}
|
||||||
config.hPath = hPathList.join(" ");
|
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);
|
searchPathInputElement.setAttribute("title", config.hPath);
|
||||||
const includeElement = element.querySelector("#searchInclude");
|
const includeElement = element.querySelector("#searchInclude");
|
||||||
includeElement.classList.remove("b3-button--cancel");
|
includeElement.classList.remove("b3-button--cancel");
|
||||||
@ -371,8 +420,8 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
|||||||
icon: "iconSearch",
|
icon: "iconSearch",
|
||||||
title: window.siyuan.languages.search,
|
title: window.siyuan.languages.search,
|
||||||
callback(tab) {
|
callback(tab) {
|
||||||
config.k = searchInputElement.value
|
config.k = searchInputElement.value;
|
||||||
config.r = replaceInputElement.value
|
config.r = replaceInputElement.value;
|
||||||
const asset = new Search({
|
const asset = new Search({
|
||||||
tab,
|
tab,
|
||||||
config
|
config
|
||||||
@ -394,7 +443,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
} else if (target.id === "searchMore") {
|
} else if (target.id === "searchMore") {
|
||||||
addConfigMoreMenu(config, edit, element, event);
|
addConfigMoreMenu(config, edit, element, event, criteriaData);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
@ -633,10 +682,10 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
|||||||
return edit;
|
return edit;
|
||||||
};
|
};
|
||||||
|
|
||||||
const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element: Element, event: MouseEvent) => {
|
const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element: Element, event: MouseEvent, criteriaData: ISearchOption[]) => {
|
||||||
const criteria = await fetchSyncPost("/api/storage/getCriteria");
|
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
const sortMenu = [{
|
const sortMenu = [{
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.type,
|
label: window.siyuan.languages.type,
|
||||||
current: config.sort === 0,
|
current: config.sort === 0,
|
||||||
click() {
|
click() {
|
||||||
@ -644,6 +693,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
inputEvent(element, config, undefined, edit);
|
inputEvent(element, config, undefined, edit);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.createdASC,
|
label: window.siyuan.languages.createdASC,
|
||||||
current: config.sort === 1,
|
current: config.sort === 1,
|
||||||
click() {
|
click() {
|
||||||
@ -651,6 +701,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
inputEvent(element, config, undefined, edit);
|
inputEvent(element, config, undefined, edit);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.createdDESC,
|
label: window.siyuan.languages.createdDESC,
|
||||||
current: config.sort === 2,
|
current: config.sort === 2,
|
||||||
click() {
|
click() {
|
||||||
@ -658,6 +709,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
inputEvent(element, config, undefined, edit);
|
inputEvent(element, config, undefined, edit);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.modifiedASC,
|
label: window.siyuan.languages.modifiedASC,
|
||||||
current: config.sort === 3,
|
current: config.sort === 3,
|
||||||
click() {
|
click() {
|
||||||
@ -665,6 +717,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
inputEvent(element, config, undefined, edit);
|
inputEvent(element, config, undefined, edit);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.modifiedDESC,
|
label: window.siyuan.languages.modifiedDESC,
|
||||||
current: config.sort === 4,
|
current: config.sort === 4,
|
||||||
click() {
|
click() {
|
||||||
@ -672,6 +725,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
inputEvent(element, config, undefined, edit);
|
inputEvent(element, config, undefined, edit);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.sortByRankAsc,
|
label: window.siyuan.languages.sortByRankAsc,
|
||||||
current: config.sort === 6,
|
current: config.sort === 6,
|
||||||
click() {
|
click() {
|
||||||
@ -679,6 +733,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
inputEvent(element, config, undefined, edit);
|
inputEvent(element, config, undefined, edit);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.sortByRankDesc,
|
label: window.siyuan.languages.sortByRankDesc,
|
||||||
current: config.sort === 7,
|
current: config.sort === 7,
|
||||||
click() {
|
click() {
|
||||||
@ -688,6 +743,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
}];
|
}];
|
||||||
if (config.group === 1) {
|
if (config.group === 1) {
|
||||||
sortMenu.push({
|
sortMenu.push({
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.sortByContent,
|
label: window.siyuan.languages.sortByContent,
|
||||||
current: config.sort === 5,
|
current: config.sort === 5,
|
||||||
click() {
|
click() {
|
||||||
@ -697,14 +753,17 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.sort,
|
label: window.siyuan.languages.sort,
|
||||||
type: "submenu",
|
type: "submenu",
|
||||||
submenu: sortMenu,
|
submenu: sortMenu,
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.group,
|
label: window.siyuan.languages.group,
|
||||||
type: "submenu",
|
type: "submenu",
|
||||||
submenu: [{
|
submenu: [{
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.noGroupBy,
|
label: window.siyuan.languages.noGroupBy,
|
||||||
current: config.group === 0,
|
current: config.group === 0,
|
||||||
click() {
|
click() {
|
||||||
@ -716,6 +775,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
inputEvent(element, config, undefined, edit);
|
inputEvent(element, config, undefined, edit);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.groupByDoc,
|
label: window.siyuan.languages.groupByDoc,
|
||||||
current: config.group === 1,
|
current: config.group === 1,
|
||||||
click() {
|
click() {
|
||||||
@ -728,9 +788,11 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
|
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
|
||||||
const isPopover = hasClosestByClassName(element, "b3-dialog__container");
|
const isPopover = hasClosestByClassName(element, "b3-dialog__container");
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.layout,
|
label: window.siyuan.languages.layout,
|
||||||
type: "submenu",
|
type: "submenu",
|
||||||
submenu: [{
|
submenu: [{
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.topBottomLayout,
|
label: window.siyuan.languages.topBottomLayout,
|
||||||
current: isPopover ? localData.layout === 0 : localData.layoutTab === 0,
|
current: isPopover ? localData.layout === 0 : localData.layoutTab === 0,
|
||||||
click() {
|
click() {
|
||||||
@ -751,6 +813,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||||||
setStorageVal(Constants.LOCAL_SEARCHKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]);
|
setStorageVal(Constants.LOCAL_SEARCHKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.leftRightLayout,
|
label: window.siyuan.languages.leftRightLayout,
|
||||||
current: isPopover ? localData.layout === 1 : localData.layoutTab === 1,
|
current: isPopover ? localData.layout === 1 : localData.layoutTab === 1,
|
||||||
click() {
|
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({type: "separator"}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.saveCriterion,
|
label: window.siyuan.languages.saveCriterion,
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
click() {
|
click() {
|
||||||
const saveDialog = new Dialog({
|
const saveDialog = new Dialog({
|
||||||
title: window.siyuan.languages.saveCriterion,
|
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;
|
config.r = (element.querySelector("#replaceInput") as HTMLInputElement).value;
|
||||||
const criterion = config;
|
const criterion = config;
|
||||||
criterion.name = value;
|
criterion.name = value;
|
||||||
|
criteriaData.push(Object.assign({}, criterion));
|
||||||
fetchPost("/api/storage/setCriterion", {criterion}, () => {
|
fetchPost("/api/storage/setCriterion", {criterion}, () => {
|
||||||
saveDialog.destroy();
|
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);
|
}).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({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.removeCriterion,
|
label: window.siyuan.languages.removeCriterion,
|
||||||
click() {
|
click() {
|
||||||
updateConfig(element, {
|
updateConfig(element, {
|
||||||
@ -893,7 +928,7 @@ const updateConfig = (element: Element, item: ISearchOption, config: ISearchOpti
|
|||||||
}
|
}
|
||||||
const searchPathInputElement = element.querySelector("#searchPathInput")
|
const searchPathInputElement = element.querySelector("#searchPathInput")
|
||||||
if (item.hPath) {
|
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);
|
searchPathInputElement.setAttribute("title", item.hPath);
|
||||||
} else {
|
} else {
|
||||||
searchPathInputElement.innerHTML = "";
|
searchPathInputElement.innerHTML = "";
|
||||||
@ -1087,6 +1122,7 @@ const addConfigFilterMenu = (config: ISearchOption, edit: Protyle, element: Elem
|
|||||||
const addQueryMenu = (config: ISearchOption, edit: Protyle, element: Element) => {
|
const addQueryMenu = (config: ISearchOption, edit: Protyle, element: Element) => {
|
||||||
const searchSyntaxCheckElement = element.querySelector("#searchSyntaxCheck");
|
const searchSyntaxCheckElement = element.querySelector("#searchSyntaxCheck");
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.keyword,
|
label: window.siyuan.languages.keyword,
|
||||||
current: config.method === 0,
|
current: config.method === 0,
|
||||||
click() {
|
click() {
|
||||||
@ -1096,6 +1132,7 @@ const addQueryMenu = (config: ISearchOption, edit: Protyle, element: Element) =>
|
|||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.querySyntax,
|
label: window.siyuan.languages.querySyntax,
|
||||||
current: config.method === 1,
|
current: config.method === 1,
|
||||||
click() {
|
click() {
|
||||||
@ -1105,6 +1142,7 @@ const addQueryMenu = (config: ISearchOption, edit: Protyle, element: Element) =>
|
|||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: "SQL",
|
label: "SQL",
|
||||||
current: config.method === 2,
|
current: config.method === 2,
|
||||||
click() {
|
click() {
|
||||||
@ -1114,6 +1152,7 @@ const addQueryMenu = (config: ISearchOption, edit: Protyle, element: Element) =>
|
|||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.regex,
|
label: window.siyuan.languages.regex,
|
||||||
current: config.method === 3,
|
current: config.method === 3,
|
||||||
click() {
|
click() {
|
||||||
|
Loading…
Reference in New Issue
Block a user