Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/16428

Vanessabdd375612748
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index eb03a2eca3..78696b040c 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -46,6 +46,7 @@ import {isSupportCSSHL, searchMarkRender} from "../protyle/render/searchMarkRend
import {saveKeyList, toggleAssetHistory, toggleReplaceHistory, toggleSearchHistory} from "./toggleHistory";
import {highlightById} from "../util/highlightById";
import {getSelectionOffset} from "../protyle/util/selection";
+import {electronUndo} from "../protyle/undo";
export const openGlobalSearch = (app: App, text: string, replace: boolean, searchData?: Config.IUILayoutTabSearchConfig) => {
text = text.trim();
@@ -890,6 +891,12 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
}
saveKeyList("keys", searchInputElement.value);
});
+ searchInputElement.addEventListener("keydown", (event) => {
+ electronUndo(event);
+ });
+ replaceInputElement.addEventListener("keydown", (event) => {
+ electronUndo(event);
+ });
addClearButton({
inputElement: searchInputElement,
right: 8,
@@ -914,7 +921,7 @@ export const openSearchEditor = (options: {
id?: string,
cb?: () => void
}) => {
- const currentRange = options.protyle.highlight.ranges[options.protyle.highlight.rangeIndex];
+ let currentRange = options.protyle.highlight.ranges[options.protyle.highlight.rangeIndex];
if (currentRange) {
const rangeBlockElement = hasClosestBlock(currentRange.startContainer);
if (rangeBlockElement) {
@@ -928,12 +935,15 @@ export const openSearchEditor = (options: {
zoomInId: options.protyle.block.showAll ? options.protyle.block.id : undefined
};
window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.protyle.block.rootID] = scrollAttr;
+ if (offset.start === offset.end) {
+ currentRange = null;
+ }
}
}
checkFold(options.id, (zoomIn) => {
openFileById({
app: options.protyle.app,
- id:options.id,
+ id: options.id,
action: currentRange ?
(zoomIn ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_SCROLL, Constants.CB_GET_SEARCH] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_SCROLL, Constants.CB_GET_SEARCH]) :
(zoomIn ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_HL]),