mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +01:00
🚨
This commit is contained in:
parent
80dc5d1082
commit
7beee6c57c
6 changed files with 14 additions and 16 deletions
|
|
@ -34,7 +34,7 @@ export const unicode2Emoji = (unicode: string, assic = false, className = "", ne
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (needSpan) {
|
if (needSpan) {
|
||||||
emoji = `<span class="${className}">${emoji}</span>`
|
emoji = `<span class="${className}">${emoji}</span>`;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// 自定义表情搜索报错 https://github.com/siyuan-note/siyuan/issues/5883
|
// 自定义表情搜索报错 https://github.com/siyuan-note/siyuan/issues/5883
|
||||||
|
|
|
||||||
|
|
@ -437,7 +437,7 @@ export const hintMoveBlock = (pathString: string, sourceElements: Element[], pro
|
||||||
if (pathString === "/") {
|
if (pathString === "/") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const parentID = getDisplayName(pathString, true, true)
|
const parentID = getDisplayName(pathString, true, true);
|
||||||
if (protyle.block.rootID === parentID) {
|
if (protyle.block.rootID === parentID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export class Search extends Model {
|
||||||
});
|
});
|
||||||
this.element = options.tab.panelElement as HTMLElement;
|
this.element = options.tab.panelElement as HTMLElement;
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
this.edit = genSearch(this.config, this.element)
|
this.edit = genSearch(this.config, this.element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateSearch(text: string, replace: boolean) {
|
public updateSearch(text: string, replace: boolean) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import {escapeHtml} from "../util/escape";
|
import {escapeHtml} from "../util/escape";
|
||||||
import {getIconByType} from "../editor/getIcon";
|
import {getNotebookName, pathPosix} from "../util/pathName";
|
||||||
import {getDisplayName, getNotebookName, pathPosix} from "../util/pathName";
|
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {Protyle} from "../protyle";
|
|
||||||
import {Dialog} from "../dialog";
|
import {Dialog} from "../dialog";
|
||||||
import {fetchSyncPost} from "../util/fetch";
|
import {fetchSyncPost} from "../util/fetch";
|
||||||
import {focusByRange} from "../protyle/util/selection";
|
import {focusByRange} from "../protyle/util/selection";
|
||||||
|
|
@ -108,6 +106,6 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
|
||||||
types: localData.types
|
types: localData.types
|
||||||
}, dialog.element.querySelector(".b3-dialog__container").lastElementChild, () => {
|
}, dialog.element.querySelector(".b3-dialog__container").lastElementChild, () => {
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
})
|
});
|
||||||
dialog.element.firstElementChild.setAttribute("style", "z-index:199"); // https://github.com/siyuan-note/siyuan/issues/3515
|
dialog.element.firstElementChild.setAttribute("style", "z-index:199"); // https://github.com/siyuan-note/siyuan/issues/3515
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
||||||
<div id="searchList" class="search__list b3-list b3-list--background search__list"></div>
|
<div id="searchList" class="search__list b3-list b3-list--background search__list"></div>
|
||||||
<div id="searchPreview" class="fn__flex-1 search__preview"></div>
|
<div id="searchPreview" class="fn__flex-1 search__preview"></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 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;
|
||||||
|
|
@ -162,7 +162,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
||||||
searchInputElement.select();
|
searchInputElement.select();
|
||||||
|
|
||||||
element.addEventListener("click", (event: MouseEvent) => {
|
element.addEventListener("click", (event: MouseEvent) => {
|
||||||
let target = event.target as HTMLElement
|
let target = event.target as HTMLElement;
|
||||||
while (target && !target.isSameNode(element)) {
|
while (target && !target.isSameNode(element)) {
|
||||||
if (target.classList.contains("search__rmpath")) {
|
if (target.classList.contains("search__rmpath")) {
|
||||||
config.idPath = "";
|
config.idPath = "";
|
||||||
|
|
@ -227,7 +227,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
} else if (target.id === "searchRefresh") {
|
} else if (target.id === "searchRefresh") {
|
||||||
inputTimeout = inputEvent(element, config, inputTimeout, edit, false)
|
inputTimeout = inputEvent(element, config, inputTimeout, edit, false);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
|
|
@ -486,7 +486,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
||||||
});
|
});
|
||||||
inputTimeout = inputEvent(element, config, inputTimeout, edit, false);
|
inputTimeout = inputEvent(element, config, inputTimeout, edit, false);
|
||||||
return edit;
|
return edit;
|
||||||
}
|
};
|
||||||
|
|
||||||
const addConfigMenu = (config: ISearchOption, lang: string, key: "mathBlock" | "table" | "blockquote" | "superBlock" | "paragraph" | "document" | "heading" | "list" | "listItem" | "codeBlock" | "htmlBlock",
|
const addConfigMenu = (config: ISearchOption, lang: string, key: "mathBlock" | "table" | "blockquote" | "superBlock" | "paragraph" | "document" | "heading" | "list" | "listItem" | "codeBlock" | "htmlBlock",
|
||||||
edit: Protyle, element: Element) => {
|
edit: Protyle, element: Element) => {
|
||||||
|
|
@ -505,7 +505,7 @@ const addConfigMenu = (config: ISearchOption, lang: string, key: "mathBlock" | "
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
};
|
||||||
|
|
||||||
const getKey = (element: HTMLElement) => {
|
const getKey = (element: HTMLElement) => {
|
||||||
const keys: string[] = [];
|
const keys: string[] = [];
|
||||||
|
|
@ -647,7 +647,7 @@ const inputEvent = (element: Element, config: ISearchOption, inputTimeout: numbe
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (saveConfig) {
|
if (saveConfig) {
|
||||||
config.k = inputValue
|
config.k = inputValue;
|
||||||
if (!element.parentElement.getAttribute("data-id")) {
|
if (!element.parentElement.getAttribute("data-id")) {
|
||||||
localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
|
localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
|
||||||
}
|
}
|
||||||
|
|
@ -673,7 +673,7 @@ ${unicode2Emoji(getNotebookIcon(item.box) || Constants.SIYUAN_IMAGE_NOTE, false,
|
||||||
${unicode2Emoji(childItem.ial.icon, false, "b3-list-item__graphic", true)}
|
${unicode2Emoji(childItem.ial.icon, false, "b3-list-item__graphic", true)}
|
||||||
<span class="b3-list-item__text">${childItem.content}</span>
|
<span class="b3-list-item__text">${childItem.content}</span>
|
||||||
</div>`;
|
</div>`;
|
||||||
})
|
});
|
||||||
resultHTML += "</div>";
|
resultHTML += "</div>";
|
||||||
} else {
|
} else {
|
||||||
const title = escapeHtml(getNotebookName(item.box)) + getDisplayName(item.hPath, false);
|
const title = escapeHtml(getNotebookName(item.box)) + getDisplayName(item.hPath, false);
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ export const globalShortcut = () => {
|
||||||
}
|
}
|
||||||
const originalElement = switchDialog.element.querySelector('[data-original="true"]');
|
const originalElement = switchDialog.element.querySelector('[data-original="true"]');
|
||||||
if (originalElement) {
|
if (originalElement) {
|
||||||
originalElement.removeAttribute("data-original")
|
originalElement.removeAttribute("data-original");
|
||||||
}
|
}
|
||||||
} else if (event.key === "Control") {
|
} else if (event.key === "Control") {
|
||||||
let currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus");
|
let currentLiElement = switchDialog.element.querySelector(".b3-list-item--focus");
|
||||||
|
|
@ -391,7 +391,7 @@ export const globalShortcut = () => {
|
||||||
}).forEach(item => {
|
}).forEach(item => {
|
||||||
let icon = `<svg class="b3-list-item__graphic"><use xlink:href="#${item.icon}"></use></svg>`;
|
let icon = `<svg class="b3-list-item__graphic"><use xlink:href="#${item.icon}"></use></svg>`;
|
||||||
let rootId = "";
|
let rootId = "";
|
||||||
const initData = item.headElement.getAttribute("data-initdata")
|
const initData = item.headElement.getAttribute("data-initdata");
|
||||||
if (item.model instanceof Editor) {
|
if (item.model instanceof Editor) {
|
||||||
rootId = ` data-node-id="${item.model.editor.protyle.block.rootID}"`;
|
rootId = ` data-node-id="${item.model.editor.protyle.block.rootID}"`;
|
||||||
icon = unicode2Emoji(item.docIcon || Constants.SIYUAN_IMAGE_FILE, false, "b3-list-item__graphic", true);
|
icon = unicode2Emoji(item.docIcon || Constants.SIYUAN_IMAGE_FILE, false, "b3-list-item__graphic", true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue