diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html
index b250240ae..2874ba004 100644
--- a/app/appearance/icons/index.html
+++ b/app/appearance/icons/index.html
@@ -422,7 +422,7 @@
- iconRegex
+ iconRegex
@@ -239,6 +241,34 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
break;
} else if (target.id === "searchFilter") {
window.siyuan.menus.menu.remove();
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: `${window.siyuan.languages.includeChildDoc}
+
`,
+ bind(menuItemElement) {
+ menuItemElement.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
+ const inputElement = menuItemElement.querySelector("input");
+ if (event.target.tagName !== "INPUT") {
+ inputElement.checked = !inputElement.checked;
+ }
+ let reload = false;
+ if (!inputElement.checked) {
+ if (!config.idPath.endsWith(".sy") && config.idPath.split("/").length > 1) {
+ config.idPath = config.idPath + ".sy";
+ reload = true;
+ }
+ } else {
+ if (config.idPath.endsWith(".sy")) {
+ config.idPath = config.idPath.replace(".sy", "");
+ reload = true;
+ }
+ }
+ if (reload) {
+ inputTimeout = inputEvent(element, config, inputTimeout, edit);
+ }
+ window.siyuan.menus.menu.remove();
+ });
+ }
+ }).element);
addConfigMenu(config, window.siyuan.languages.math, "mathBlock", edit, element);
addConfigMenu(config, window.siyuan.languages.table, "table", edit, element);
addConfigMenu(config, window.siyuan.languages.quote, "blockquote", edit, element);
@@ -254,30 +284,10 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
event.stopPropagation();
event.preventDefault();
break;
- } else if (target.id === "includeChildCheck") {
- target.classList.toggle("b3-button--cancel");
- let reload = false;
- if (target.classList.contains("b3-button--cancel")) {
- if (!config.idPath.endsWith(".sy") && config.idPath.split("/").length > 1) {
- config.idPath = config.idPath + ".sy";
- reload = true;
- }
- } else {
- if (config.idPath.endsWith(".sy")) {
- config.idPath = config.idPath.replace(".sy", "");
- reload = true;
- }
- }
- if (reload) {
- inputTimeout = inputEvent(element, config, inputTimeout, edit);
- }
- event.stopPropagation();
- event.preventDefault();
- break;
} else if (target.id === "searchSyntaxCheck") {
- target.classList.toggle("b3-button--cancel");
- config.querySyntax = !target.classList.contains("b3-button--cancel");
- inputTimeout = inputEvent(element, config, inputTimeout, edit);
+ window.siyuan.menus.menu.remove();
+ addQueryMenu(config, edit, element);
+ window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16}, true);
event.stopPropagation();
event.preventDefault();
break;
@@ -507,6 +517,41 @@ const addConfigMenu = (config: ISearchOption, lang: string, key: "mathBlock" | "
}).element);
};
+const addQueryMenu = (config: ISearchOption, edit: Protyle, element: Element) => {
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.text,
+ current: config.method === 0,
+ click() {
+ config.method = 0;
+ inputEvent(element, config, undefined, edit);
+ }
+ }).element);
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.querySyntax,
+ current: config.method === 1,
+ click() {
+ config.method = 1;
+ inputEvent(element, config, undefined, edit);
+ }
+ }).element);
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: "SQL",
+ current: config.method === 2,
+ click() {
+ config.method = 2;
+ inputEvent(element, config, undefined, edit);
+ }
+ }).element);
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.regex,
+ current: config.method === 3,
+ click() {
+ config.method = 3;
+ inputEvent(element, config, undefined, edit);
+ }
+ }).element);
+};
+
const getKey = (element: HTMLElement) => {
const keys: string[] = [];
element.querySelectorAll("mark").forEach(item => {
@@ -636,7 +681,7 @@ const inputEvent = (element: Element, config: ISearchOption, inputTimeout: numbe
} else {
fetchPost("/api/search/fullTextSearchBlock", {
query: inputValue,
- querySyntax: config.querySyntax,
+ method: config.method,
types: config.types,
path: config.idPath || "",
groupBy: config.group, // 0:不分组,1:按文档分组
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index b753b02e1..9d9e097e7 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -51,7 +51,7 @@ interface Window {
interface ISearchOption {
group: number,
hasReplace: boolean,
- querySyntax: boolean,
+ method: number // 0:文本,1:查询语法,2:SQL,3:正则表达式
hPath: string
idPath: string
k: string