Vanessa 2023-12-22 12:30:12 +08:00
parent badaf6ffb8
commit 33b9a6d331
18 changed files with 78 additions and 41 deletions

View file

@ -251,9 +251,9 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
} }
let searchKey = ""; let searchKey = "";
if (matchHotKey(window.siyuan.config.keymap.general.replace.custom, event)) { if (matchHotKey(window.siyuan.config.keymap.general.replace.custom, event)) {
searchKey = window.siyuan.config.keymap.general.replace.custom; searchKey = Constants.DIALOG_REPLACE;
} else if (matchHotKey(window.siyuan.config.keymap.general.search.custom, event)) { } else if (matchHotKey(window.siyuan.config.keymap.general.search.custom, event)) {
searchKey = window.siyuan.config.keymap.general.search.custom; searchKey = Constants.DIALOG_SEARCH;
} }
if (!isFileFocus && searchKey) { if (!isFileFocus && searchKey) {
if (range && protyle.element.contains(range.startContainer)) { if (range && protyle.element.contains(range.startContainer)) {
@ -629,9 +629,9 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
let searchKey = ""; let searchKey = "";
if (matchHotKey(window.siyuan.config.keymap.general.replace.custom, event)) { if (matchHotKey(window.siyuan.config.keymap.general.replace.custom, event)) {
searchKey = window.siyuan.config.keymap.general.replace.custom; searchKey = Constants.DIALOG_REPLACE;
} else if (matchHotKey(window.siyuan.config.keymap.general.search.custom, event)) { } else if (matchHotKey(window.siyuan.config.keymap.general.search.custom, event)) {
searchKey = window.siyuan.config.keymap.general.search.custom; searchKey = Constants.DIALOG_SEARCH;
} }
if (searchKey) { if (searchKey) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
@ -1045,13 +1045,13 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
["0", "1", "2", "3", "4", "j", "k", "l", ";", "s", " ", "p", "enter"].includes(event.key.toLowerCase())) { ["0", "1", "2", "3", "4", "j", "k", "l", ";", "s", " ", "p", "enter"].includes(event.key.toLowerCase())) {
let cardElement: Element; let cardElement: Element;
window.siyuan.dialogs.find(item => { window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.riffCard.custom) { if (item.element.getAttribute("data-key") === Constants.DIALOG_OPENCARD) {
cardElement = item.element; cardElement = item.element;
return true; return true;
} }
}); });
if (!cardElement) { if (!cardElement) {
cardElement = document.querySelector(`.layout__wnd--active div[data-key="${window.siyuan.config.keymap.general.riffCard.custom}"]:not(.fn__none)`); cardElement = document.querySelector(`.layout__wnd--active div[data-key="${Constants.DIALOG_OPENCARD}"]:not(.fn__none)`);
} }
if (cardElement) { if (cardElement) {
event.preventDefault(); event.preventDefault();
@ -1173,7 +1173,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
<div class="switch-doc__path"></div> <div class="switch-doc__path"></div>
</div>`, </div>`,
}); });
switchDialog.element.setAttribute("data-key", window.siyuan.config.keymap.general.goToEditTabNext.custom); switchDialog.element.setAttribute("data-key", Constants.DIALOG_SWITCHTAB);
// 需移走光标,否则编辑器会继续监听并执行按键操作 // 需移走光标,否则编辑器会继续监听并执行按键操作
switchDialog.element.querySelector("input").focus(); switchDialog.element.querySelector("input").focus();
if (isMac()) { if (isMac()) {
@ -1190,7 +1190,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
if (isNotCtrl(event) && !event.shiftKey && !event.altKey && if (isNotCtrl(event) && !event.shiftKey && !event.altKey &&
(event.key.startsWith("Arrow") || event.key === "Enter")) { (event.key.startsWith("Arrow") || event.key === "Enter")) {
const openRecentDocsDialog = window.siyuan.dialogs.find(item => { const openRecentDocsDialog = window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) { if (item.element.getAttribute("data-key") === Constants.DIALOG_RECENTDOCS) {
return true; return true;
} }
}); });
@ -1214,7 +1214,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
if (event.key === "ArrowUp" || event.key === "ArrowDown") { if (event.key === "ArrowUp" || event.key === "ArrowDown") {
const viewCardsDialog = window.siyuan.dialogs.find(item => { const viewCardsDialog = window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === "viewCards") { if (item.element.getAttribute("data-key") === Constants.DIALOG_VIEWCARDS) {
return true; return true;
} }
}); });
@ -1654,11 +1654,11 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
let searchKey = ""; let searchKey = "";
if (matchHotKey(window.siyuan.config.keymap.general.replace.custom, event)) { if (matchHotKey(window.siyuan.config.keymap.general.replace.custom, event)) {
searchKey = window.siyuan.config.keymap.general.replace.custom; searchKey = Constants.DIALOG_REPLACE;
} else if (!hasClosestByClassName(target, "pdf__outer") && matchHotKey(window.siyuan.config.keymap.general.search.custom, event)) { } else if (!hasClosestByClassName(target, "pdf__outer") && matchHotKey(window.siyuan.config.keymap.general.search.custom, event)) {
searchKey = window.siyuan.config.keymap.general.search.custom; searchKey = Constants.DIALOG_SEARCH;
} else if (matchHotKey(window.siyuan.config.keymap.general.globalSearch.custom, event)) { } else if (matchHotKey(window.siyuan.config.keymap.general.globalSearch.custom, event)) {
searchKey = window.siyuan.config.keymap.general.globalSearch.custom; searchKey = Constants.DIALOG_GLOBALSEARCH;
} }
if (searchKey) { if (searchKey) {
if (getSelection().rangeCount > 0) { if (getSelection().rangeCount > 0) {

View file

@ -12,7 +12,7 @@ export const windowKeyUp = (app: App, event: KeyboardEvent) => {
window.siyuan.shiftIsPressed = false; window.siyuan.shiftIsPressed = false;
window.siyuan.altIsPressed = false; window.siyuan.altIsPressed = false;
const switchDialog = window.siyuan.dialogs.find(item => { const switchDialog = window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.goToEditTabNext.custom) { if (item.element.getAttribute("data-key") === Constants.DIALOG_SWITCHTAB) {
return true; return true;
} }
}); });

View file

@ -69,7 +69,7 @@ ${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_FILE, "b3-list-item__graphic
export const openRecentDocs = () => { export const openRecentDocs = () => {
const openRecentDocsDialog = window.siyuan.dialogs.find(item => { const openRecentDocsDialog = window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) { if (item.element.getAttribute("data-key") === Constants.DIALOG_RECENTDOCS) {
return true; return true;
} }
}); });
@ -113,7 +113,7 @@ export const openRecentDocs = () => {
} }
getHTML(response.data, dialog.element, searchElement.value); getHTML(response.data, dialog.element, searchElement.value);
}); });
dialog.element.setAttribute("data-key", window.siyuan.config.keymap.general.recentDocs.custom); dialog.element.setAttribute("data-key", Constants.DIALOG_RECENTDOCS);
dialog.element.addEventListener("click", (event) => { dialog.element.addEventListener("click", (event) => {
const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item"); const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
if (liElement) { if (liElement) {

View file

@ -37,7 +37,7 @@ export const genCardItem = (item: ICardPackage) => {
export const makeCard = (app: App, ids: string[]) => { export const makeCard = (app: App, ids: string[]) => {
window.siyuan.dialogs.find(item => { window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === "makeCard") { if (item.element.getAttribute("data-key") === Constants.DIALOG_MAKECARD) {
hideElements(["dialog"]); hideElements(["dialog"]);
return true; return true;
} }
@ -67,7 +67,7 @@ export const makeCard = (app: App, ids: string[]) => {
<ul class="b3-list b3-list--background fn__flex-1">${html}</ul> <ul class="b3-list b3-list--background fn__flex-1">${html}</ul>
</div>`, </div>`,
}); });
dialog.element.setAttribute("data-key", "makeCard"); dialog.element.setAttribute("data-key", Constants.DIALOG_MAKECARD);
dialog.element.addEventListener("click", (event) => { dialog.element.addEventListener("click", (event) => {
let target = event.target as HTMLElement; let target = event.target as HTMLElement;
while (target && !target.isSameNode(dialog.element)) { while (target && !target.isSameNode(dialog.element)) {

View file

@ -178,7 +178,7 @@ export const bindCardEvent = (options: {
}); });
}); });
} }
options.element.setAttribute("data-key", window.siyuan.config.keymap.general.riffCard.custom); options.element.setAttribute("data-key", Constants.DIALOG_OPENCARD);
const countElement = options.element.querySelector('[data-type="count"] span'); const countElement = options.element.querySelector('[data-type="count"] span');
countElement.innerHTML = (index + 1).toString(); countElement.innerHTML = (index + 1).toString();
const actionElements = options.element.querySelectorAll(".card__action"); const actionElements = options.element.querySelectorAll(".card__action");
@ -456,7 +456,7 @@ export const openCardByData = (app: App, cardsData: {
unreviewedOldCardCount: number unreviewedOldCardCount: number
}, cardType: TCardType, id?: string, title?: string) => { }, cardType: TCardType, id?: string, title?: string) => {
const exit = window.siyuan.dialogs.find(item => { const exit = window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.riffCard.custom) { if (item.element.getAttribute("data-key") === Constants.DIALOG_OPENCARD) {
item.destroy(); item.destroy();
return true; return true;
} }
@ -464,11 +464,13 @@ export const openCardByData = (app: App, cardsData: {
if (exit) { if (exit) {
return; return;
} }
const dialogPosition = window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION][Constants.DIALOG_OPENCARD];
const dialog = new Dialog({ const dialog = new Dialog({
content: genCardHTML({id, cardType, cardsData, isTab: false}), content: genCardHTML({id, cardType, cardsData, isTab: false}),
width: isMobile() ? "100vw" : "80vw", width: dialogPosition ? dialogPosition.width + "px" : (isMobile() ? "100vw" : "80vw"),
height: isMobile() ? "100vh" : "70vh", height: dialogPosition ? dialogPosition.height + "px" : (isMobile() ? "100vh" : "70vh"),
left: dialogPosition?.left,
top: dialogPosition?.top,
destroyCallback() { destroyCallback() {
if (editor) { if (editor) {
editor.destroy(); editor.destroy();

View file

@ -78,7 +78,7 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr
if (response.data.pageCount > 1) { if (response.data.pageCount > 1) {
nextElement.removeAttribute("disabled"); nextElement.removeAttribute("disabled");
} }
dialog.element.setAttribute("data-key", "viewCards"); dialog.element.setAttribute("data-key", Constants.DIALOG_VIEWCARDS);
dialog.element.addEventListener("click", (event) => { dialog.element.addEventListener("click", (event) => {
if (typeof event.detail === "string") { if (typeof event.detail === "string") {
let currentElement = listElement.querySelector(".b3-list-item--focus"); let currentElement = listElement.querySelector(".b3-list-item--focus");

View file

@ -101,8 +101,20 @@ export abstract class Constants {
public static readonly LOCAL_PLUGINTOPUNPIN = "local-plugintopunpin"; public static readonly LOCAL_PLUGINTOPUNPIN = "local-plugintopunpin";
public static readonly LOCAL_FLASHCARD = "local-flashcard"; public static readonly LOCAL_FLASHCARD = "local-flashcard";
public static readonly LOCAL_FILEPOSITION = "local-fileposition"; public static readonly LOCAL_FILEPOSITION = "local-fileposition";
public static readonly LOCAL_DIALOGPOSITION = "local-dialogposition";
public static readonly LOCAL_SESSION_FIRSTLOAD = "local-session-firstload"; public static readonly LOCAL_SESSION_FIRSTLOAD = "local-session-firstload";
// dialog
public static readonly DIALOG_OPENCARD = "dialog-opencard";
public static readonly DIALOG_MAKECARD = "dialog-makecard";
public static readonly DIALOG_VIEWCARDS = "dialog-viewcards";
public static readonly DIALOG_DIALYNOTE = "dialog-dialynote";
public static readonly DIALOG_RECENTDOCS = "dialog-recentdocs";
public static readonly DIALOG_SWITCHTAB = "dialog-switchtab";
public static readonly DIALOG_SEARCH = "dialog-search";
public static readonly DIALOG_REPLACE = "dialog-replace";
public static readonly DIALOG_GLOBALSEARCH = "dialog-globalsearch";
// timeout // timeout
public static readonly TIMEOUT_DBLCLICK = 190; public static readonly TIMEOUT_DBLCLICK = 190;
public static readonly TIMEOUT_INPUT = 256; public static readonly TIMEOUT_INPUT = 256;

View file

@ -18,6 +18,8 @@ export class Dialog {
title?: string, title?: string,
transparent?: boolean, transparent?: boolean,
content: string, content: string,
left?: number,
top?: number,
width?: string, width?: string,
height?: string, height?: string,
destroyCallback?: (options?: IObject) => void, destroyCallback?: (options?: IObject) => void,
@ -32,9 +34,9 @@ export class Dialog {
this.destroyCallback = options.destroyCallback; this.destroyCallback = options.destroyCallback;
this.element = document.createElement("div") as HTMLElement; this.element = document.createElement("div") as HTMLElement;
this.element.innerHTML = `<div class="b3-dialog" style="z-index: ${++window.siyuan.zIndex};"> this.element.innerHTML = `<div class="b3-dialog" style="z-index: ${++window.siyuan.zIndex};${typeof options.left === "number" ? "display:block" : ""}">
<div class="b3-dialog__scrim"${options.transparent ? 'style="background-color:transparent"' : ""}></div> <div class="b3-dialog__scrim"${options.transparent ? 'style="background-color:transparent"' : ""}></div>
<div class="b3-dialog__container" style="width:${options.width || "auto"};height:${options.height || "auto"}"> <div class="b3-dialog__container" style="width:${options.width || "auto"};height:${options.height || "auto"};left:${options.left}px;top:${options.top}px">
<svg ${(isMobile() && options.title) ? 'style="top:0;right:0;"' : ""} class="b3-dialog__close${(this.disableClose || options.hideCloseIcon) ? " fn__none" : ""}"><use xlink:href="#iconCloseRound"></use></svg> <svg ${(isMobile() && options.title) ? 'style="top:0;right:0;"' : ""} class="b3-dialog__close${(this.disableClose || options.hideCloseIcon) ? " fn__none" : ""}"><use xlink:href="#iconCloseRound"></use></svg>
<div class="resize__move b3-dialog__header${options.title ? "" : " fn__none"}" onselectstart="return false;">${options.title || ""}</div> <div class="resize__move b3-dialog__header${options.title ? "" : " fn__none"}" onselectstart="return false;">${options.title || ""}</div>
<div class="b3-dialog__body">${options.content}</div> <div class="b3-dialog__body">${options.content}</div>

View file

@ -1,6 +1,7 @@
import {hasClosestByClassName} from "../protyle/util/hasClosest"; import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {Constants} from "../constants"; import {Constants} from "../constants";
import {hideAllElements} from "../protyle/ui/hideElements"; import {hideAllElements} from "../protyle/ui/hideElements";
import {setStorageVal} from "../protyle/util/compatibility";
export const moveResize = (element: HTMLElement, afterCB?: (type: string) => void) => { export const moveResize = (element: HTMLElement, afterCB?: (type: string) => void) => {
element.addEventListener("mousedown", (event: MouseEvent & { target: HTMLElement }) => { element.addEventListener("mousedown", (event: MouseEvent & { target: HTMLElement }) => {
@ -133,6 +134,19 @@ export const moveResize = (element: HTMLElement, afterCB?: (type: string) => voi
documentSelf.onselectstart = null; documentSelf.onselectstart = null;
documentSelf.onselect = null; documentSelf.onselect = null;
hideAllElements(["gutter"]) hideAllElements(["gutter"])
const dialogElement = hasClosestByClassName(element, "b3-dialog--open")
if (dialogElement) {
const dialogId = dialogElement.dataset.key;
if (dialogId) {
window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION][dialogId] = {
width: parseInt(element.style.width),
height: parseInt(element.style.height),
left: parseInt(element.style.left),
top: parseInt(element.style.top),
}
setStorageVal(Constants.LOCAL_DIALOGPOSITION, window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION]);
}
}
if (hasMove && afterCB) { if (hasMove && afterCB) {
afterCB(type); afterCB(type);
} }

View file

@ -23,6 +23,7 @@ import {openRecentDocs} from "../business/openRecentDocs";
import {openHistory} from "../history/history"; import {openHistory} from "../history/history";
import {newFile} from "../util/newFile"; import {newFile} from "../util/newFile";
import {mountHelp, newNotebook} from "../util/mount"; import {mountHelp, newNotebook} from "../util/mount";
import {Constants} from "../constants";
export const getActiveTab = (wndActive = true) => { export const getActiveTab = (wndActive = true) => {
const activeTabElement = document.querySelector(".layout__wnd--active .item--focus"); const activeTabElement = document.querySelector(".layout__wnd--active .item--focus");
@ -185,7 +186,7 @@ export const newCenterEmptyTab = (app: App) => {
if (target.id === "editorEmptySearch") { if (target.id === "editorEmptySearch") {
openSearch({ openSearch({
app, app,
hotkey: window.siyuan.config.keymap.general.globalSearch.custom, hotkey: Constants.DIALOG_GLOBALSEARCH,
}); });
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();

View file

@ -173,7 +173,7 @@ export const initBar = (app: App) => {
} else if (targetId === "barSearch") { } else if (targetId === "barSearch") {
openSearch({ openSearch({
app, app,
hotkey: window.siyuan.config.keymap.general.globalSearch.custom hotkey: Constants.DIALOG_GLOBALSEARCH
}); });
event.stopPropagation(); event.stopPropagation();
break; break;

View file

@ -33,6 +33,7 @@ import {App} from "../index";
import {afterLoadPlugin} from "../plugin/loader"; import {afterLoadPlugin} from "../plugin/loader";
import {setTitle} from "../dialog/processSystem"; import {setTitle} from "../dialog/processSystem";
import {newCenterEmptyTab, resizeTabs} from "./tabUtil"; import {newCenterEmptyTab, resizeTabs} from "./tabUtil";
import {setStorageVal} from "../protyle/util/compatibility";
export const setPanelFocus = (element: Element) => { export const setPanelFocus = (element: Element) => {
if (element.getAttribute("data-type") === "wnd") { if (element.getAttribute("data-type") === "wnd") {
@ -169,6 +170,10 @@ const dockToJSON = (dock: Dock) => {
export const resetLayout = () => { export const resetLayout = () => {
fetchPost("/api/system/setUILayout", {layout: {}}, () => { fetchPost("/api/system/setUILayout", {layout: {}}, () => {
window.siyuan.storage[Constants.LOCAL_FILEPOSITION] = {};
setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION]);
window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION] = {};
setStorageVal(Constants.LOCAL_DIALOGPOSITION, window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION]);
window.location.reload(); window.location.reload();
}); });
}; };

View file

@ -238,7 +238,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
/// #else /// #else
openSearch({ openSearch({
app, app,
hotkey: window.siyuan.config.keymap.general.search.custom, hotkey: Constants.DIALOG_SEARCH,
notebookId, notebookId,
}); });
/// #endif /// #endif
@ -269,7 +269,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
/// #else /// #else
openSearch({ openSearch({
app, app,
hotkey: window.siyuan.config.keymap.general.replace.custom, hotkey: Constants.DIALOG_REPLACE,
notebookId, notebookId,
}); });
/// #endif /// #endif
@ -564,7 +564,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
/// #else /// #else
openSearch({ openSearch({
app, app,
hotkey: window.siyuan.config.keymap.general.search.custom, hotkey: Constants.DIALOG_SEARCH,
notebookId, notebookId,
searchPath searchPath
}); });
@ -600,7 +600,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
/// #else /// #else
openSearch({ openSearch({
app, app,
hotkey: window.siyuan.config.keymap.general.replace.custom, hotkey: Constants.DIALOG_REPLACE,
notebookId, notebookId,
searchPath searchPath
}); });

View file

@ -190,7 +190,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
/// #else /// #else
openSearch({ openSearch({
app: protyle.app, app: protyle.app,
hotkey: window.siyuan.config.keymap.general.search.custom, hotkey: Constants.DIALOG_SEARCH,
notebookId: protyle.notebookId, notebookId: protyle.notebookId,
searchPath searchPath
}); });

View file

@ -188,6 +188,7 @@ export const getLocalStorage = (cb: () => void) => {
defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""} defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""}
defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = []; defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr} defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr}
defaultStorage[Constants.LOCAL_DIALOGPOSITION] = {}; // {id: IPosition}
defaultStorage[Constants.LOCAL_FLASHCARD] = { defaultStorage[Constants.LOCAL_FLASHCARD] = {
fullscreen: false fullscreen: false
}; };
@ -246,7 +247,7 @@ export const getLocalStorage = (cb: () => void) => {
[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR, [Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR,
Constants.LOCAL_EXPORTWORD, Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES, Constants.LOCAL_EXPORTWORD, Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES,
Constants.LOCAL_SEARCHDATA, Constants.LOCAL_ZOOM, Constants.LOCAL_LAYOUTS, Constants.LOCAL_AI, Constants.LOCAL_SEARCHDATA, Constants.LOCAL_ZOOM, Constants.LOCAL_LAYOUTS, Constants.LOCAL_AI,
Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD, Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD, Constants.LOCAL_DIALOGPOSITION,
Constants.LOCAL_FILEPOSITION].forEach((key) => { Constants.LOCAL_FILEPOSITION].forEach((key) => {
if (typeof response.data[key] === "string") { if (typeof response.data[key] === "string") {
try { try {

View file

@ -17,13 +17,13 @@ export const openSearch = async (options: {
if (item.element.querySelector("#searchList")) { if (item.element.querySelector("#searchList")) {
const lastKey = item.element.getAttribute("data-key"); const lastKey = item.element.getAttribute("data-key");
const replaceHeaderElement = item.element.querySelectorAll(".search__header")[1]; const replaceHeaderElement = item.element.querySelectorAll(".search__header")[1];
if (lastKey !== options.hotkey && options.hotkey === window.siyuan.config.keymap.general.replace.custom && replaceHeaderElement.classList.contains("fn__none")) { if (lastKey !== options.hotkey && options.hotkey === Constants.DIALOG_REPLACE && replaceHeaderElement.classList.contains("fn__none")) {
replaceHeaderElement.classList.remove("fn__none"); replaceHeaderElement.classList.remove("fn__none");
item.element.setAttribute("data-key", options.hotkey); item.element.setAttribute("data-key", options.hotkey);
return true; return true;
} }
const searchPathElement = item.element.querySelector("#searchPathInput"); const searchPathElement = item.element.querySelector("#searchPathInput");
if (lastKey !== options.hotkey && options.hotkey === window.siyuan.config.keymap.general.globalSearch.custom) { if (lastKey !== options.hotkey && options.hotkey === Constants.DIALOG_GLOBALSEARCH) {
if (searchPathElement.textContent !== "") { if (searchPathElement.textContent !== "") {
item.destroy(); item.destroy();
return false; return false;
@ -33,7 +33,7 @@ export const openSearch = async (options: {
return true; return true;
} }
} }
if (lastKey !== options.hotkey && options.hotkey === window.siyuan.config.keymap.general.search.custom) { if (lastKey !== options.hotkey && options.hotkey === Constants.DIALOG_SEARCH) {
if (searchPathElement.textContent === "") { if (searchPathElement.textContent === "") {
item.destroy(); item.destroy();
return false; return false;
@ -65,7 +65,7 @@ export const openSearch = async (options: {
hPath = pathPosix().join(hPath, response.data); hPath = pathPosix().join(hPath, response.data);
idPath[0] = pathPosix().join(idPath[0], options.searchPath); idPath[0] = pathPosix().join(idPath[0], options.searchPath);
} }
} else if (window.siyuan.config.keymap.general.globalSearch.custom === options.hotkey) { } else if (Constants.DIALOG_GLOBALSEARCH === options.hotkey) {
if (localData.removed) { if (localData.removed) {
hPath = ""; hPath = "";
idPath = []; idPath = [];
@ -102,7 +102,7 @@ export const openSearch = async (options: {
removed: localData.removed, removed: localData.removed,
k: options.key || localData.k, k: options.key || localData.k,
r: localData.r, r: localData.r,
hasReplace: options.hotkey === window.siyuan.config.keymap.general.replace.custom, hasReplace: options.hotkey === Constants.DIALOG_REPLACE,
method: localData.method, method: localData.method,
hPath, hPath,
idPath, idPath,

View file

@ -1014,7 +1014,7 @@ export const getQueryTip = (method: number) => {
const updateConfig = (element: Element, item: ISearchOption, config: ISearchOption, edit: Protyle) => { const updateConfig = (element: Element, item: ISearchOption, config: ISearchOption, edit: Protyle) => {
const dialogElement = hasClosestByClassName(element, "b3-dialog--open"); const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
if (dialogElement && dialogElement.getAttribute("data-key") === window.siyuan.config.keymap.general.search.custom) { if (dialogElement && dialogElement.getAttribute("data-key") === Constants.DIALOG_SEARCH) {
// https://github.com/siyuan-note/siyuan/issues/6828 // https://github.com/siyuan-note/siyuan/issues/6828
item.hPath = config.hPath; item.hPath = config.hPath;
item.idPath = config.idPath.join(",").split(","); item.idPath = config.idPath.join(",").split(",");

View file

@ -25,7 +25,7 @@ export const fetchNewDailyNote = (app: App, notebook: string) => {
export const newDailyNote = (app: App) => { export const newDailyNote = (app: App) => {
const exit = window.siyuan.dialogs.find(item => { const exit = window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.dailyNote.custom) { if (item.element.getAttribute("data-key") === Constants.DIALOG_DIALYNOTE) {
item.destroy(); item.destroy();
return true; return true;
} }
@ -74,7 +74,7 @@ export const newDailyNote = (app: App) => {
</div>`, </div>`,
width: isMobile() ? "92vw" : "520px", width: isMobile() ? "92vw" : "520px",
}); });
dialog.element.setAttribute("data-key", window.siyuan.config.keymap.general.dailyNote.custom); dialog.element.setAttribute("data-key", Constants.DIALOG_DIALYNOTE);
const btnsElement = dialog.element.querySelectorAll(".b3-button"); const btnsElement = dialog.element.querySelectorAll(".b3-button");
const selectElement = dialog.element.querySelector(".b3-select") as HTMLSelectElement; const selectElement = dialog.element.querySelector(".b3-select") as HTMLSelectElement;
selectElement.value = localNotebookId; selectElement.value = localNotebookId;