Vanessa 2025-11-27 18:20:45 +08:00
parent 4a656d3ab8
commit 50762fe6e6
3 changed files with 13 additions and 11 deletions

View file

@ -147,11 +147,12 @@ const updateConfig = (element: Element, newConfig: Config.IUILayoutTabSearchConf
} }
(document.querySelector("#toolbarSearch") as HTMLInputElement).value = newConfig.k; (document.querySelector("#toolbarSearch") as HTMLInputElement).value = newConfig.k;
(element.querySelector("#toolbarReplace") as HTMLInputElement).value = newConfig.r; (element.querySelector("#toolbarReplace") as HTMLInputElement).value = newConfig.r;
Object.assign(config, newConfig); config = JSON.parse(JSON.stringify(newConfig));
window.siyuan.storage[Constants.LOCAL_SEARCHDATA] = Object.assign({}, config); window.siyuan.storage[Constants.LOCAL_SEARCHDATA] = Object.assign({}, config);
setStorageVal(Constants.LOCAL_SEARCHDATA, window.siyuan.storage[Constants.LOCAL_SEARCHDATA]); setStorageVal(Constants.LOCAL_SEARCHDATA, window.siyuan.storage[Constants.LOCAL_SEARCHDATA]);
updateSearchResult(config, element); updateSearchResult(config, element);
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return config;
}; };
const onRecentBlocks = (data: IBlock[], config: Config.IUILayoutTabSearchConfig, const onRecentBlocks = (data: IBlock[], config: Config.IUILayoutTabSearchConfig,
@ -386,7 +387,7 @@ const initSearchEvent = (app: App, element: Element, config: Config.IUILayoutTab
target.classList.add("b3-chip--current"); target.classList.add("b3-chip--current");
criteriaData.find(item => { criteriaData.find(item => {
if (item.name === target.innerText.trim()) { if (item.name === target.innerText.trim()) {
updateConfig(element, item, config); item = updateConfig(element, item, config);
return true; return true;
} }
}); });
@ -403,7 +404,7 @@ const initSearchEvent = (app: App, element: Element, config: Config.IUILayoutTab
} }
}); });
if (target.parentElement.classList.contains("b3-chip--current")) { if (target.parentElement.classList.contains("b3-chip--current")) {
updateConfig(element, { config = updateConfig(element, {
removed: true, removed: true,
sort: 0, sort: 0,
group: 0, group: 0,
@ -545,7 +546,7 @@ const initSearchEvent = (app: App, element: Element, config: Config.IUILayoutTab
config.page = 1; config.page = 1;
updateSearchResult(config, element, true); updateSearchResult(config, element, true);
}, () => { }, () => {
updateConfig(element, { config = updateConfig(element, {
removed: true, removed: true,
sort: 0, sort: 0,
group: 0, group: 0,

View file

@ -63,12 +63,12 @@ export const openSearch = async (options: {
item.element.setAttribute("data-key", options.hotkey); item.element.setAttribute("data-key", options.hotkey);
if (options.hotkey === Constants.DIALOG_REPLACE) { if (options.hotkey === Constants.DIALOG_REPLACE) {
cloneData.hasReplace = true; cloneData.hasReplace = true;
updateConfig(searchElement, cloneData, item.data, item.editors.edit); item.data = updateConfig(searchElement, cloneData, item.data, item.editors.edit);
} else if (options.hotkey === Constants.DIALOG_GLOBALSEARCH) { } else if (options.hotkey === Constants.DIALOG_GLOBALSEARCH) {
cloneData.hasReplace = false; cloneData.hasReplace = false;
cloneData.hPath = ""; cloneData.hPath = "";
cloneData.idPath = []; cloneData.idPath = [];
updateConfig(searchElement, cloneData, item.data, item.editors.edit); item.data = updateConfig(searchElement, cloneData, item.data, item.editors.edit);
} else if (options.hotkey === Constants.DIALOG_SEARCH) { } else if (options.hotkey === Constants.DIALOG_SEARCH) {
cloneData.hasReplace = false; cloneData.hasReplace = false;
const toPath = item.editors.edit.protyle.path; const toPath = item.editors.edit.protyle.path;
@ -77,7 +77,7 @@ export const openSearch = async (options: {
cloneData.hPath = response.data[0]; cloneData.hPath = response.data[0];
item.data.idPath = cloneData.idPath; item.data.idPath = cloneData.idPath;
item.data.hPath = cloneData.hPath; item.data.hPath = cloneData.hPath;
updateConfig(searchElement, cloneData, item.data, item.editors.edit); item.data = updateConfig(searchElement, cloneData, item.data, item.editors.edit);
}); });
} }
return true; return true;

View file

@ -342,7 +342,7 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
while (target && target !== element) { while (target && target !== element) {
const type = target.getAttribute("data-type"); const type = target.getAttribute("data-type");
if (type === "removeCriterion") { if (type === "removeCriterion") {
updateConfig(element, { config = updateConfig(element, {
removed: true, removed: true,
sort: 0, sort: 0,
group: 0, group: 0,
@ -391,7 +391,7 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
target.classList.add("b3-chip--current"); target.classList.add("b3-chip--current");
criteriaData.find(item => { criteriaData.find(item => {
if (item.name === target.innerText.trim()) { if (item.name === target.innerText.trim()) {
updateConfig(element, item, config, edit); config = updateConfig(element, item, config, edit);
return true; return true;
} }
}); });
@ -408,7 +408,7 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
} }
}); });
if (target.parentElement.classList.contains("b3-chip--current")) { if (target.parentElement.classList.contains("b3-chip--current")) {
updateConfig(element, { config = updateConfig(element, {
removed: true, removed: true,
sort: 0, sort: 0,
group: 0, group: 0,
@ -604,7 +604,7 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
config.page = 1; config.page = 1;
inputEvent(element, config, edit, true); inputEvent(element, config, edit, true);
}, () => { }, () => {
updateConfig(element, { config = updateConfig(element, {
removed: true, removed: true,
sort: 0, sort: 0,
group: 0, group: 0,
@ -1013,6 +1013,7 @@ export const updateConfig = (element: Element, item: Config.IUILayoutTabSearchCo
setStorageVal(Constants.LOCAL_SEARCHDATA, window.siyuan.storage[Constants.LOCAL_SEARCHDATA]); setStorageVal(Constants.LOCAL_SEARCHDATA, window.siyuan.storage[Constants.LOCAL_SEARCHDATA]);
inputEvent(element, config, edit); inputEvent(element, config, edit);
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return config;
}; };
const scrollToCurrent = (contentElement: HTMLElement, currentRange: Range, contentRect: DOMRect) => { const scrollToCurrent = (contentElement: HTMLElement, currentRange: Range, contentRect: DOMRect) => {