mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
This commit is contained in:
parent
cad7d48320
commit
bdd3756127
1 changed files with 12 additions and 2 deletions
|
|
@ -46,6 +46,7 @@ import {isSupportCSSHL, searchMarkRender} from "../protyle/render/searchMarkRend
|
||||||
import {saveKeyList, toggleAssetHistory, toggleReplaceHistory, toggleSearchHistory} from "./toggleHistory";
|
import {saveKeyList, toggleAssetHistory, toggleReplaceHistory, toggleSearchHistory} from "./toggleHistory";
|
||||||
import {highlightById} from "../util/highlightById";
|
import {highlightById} from "../util/highlightById";
|
||||||
import {getSelectionOffset} from "../protyle/util/selection";
|
import {getSelectionOffset} from "../protyle/util/selection";
|
||||||
|
import {electronUndo} from "../protyle/undo";
|
||||||
|
|
||||||
export const openGlobalSearch = (app: App, text: string, replace: boolean, searchData?: Config.IUILayoutTabSearchConfig) => {
|
export const openGlobalSearch = (app: App, text: string, replace: boolean, searchData?: Config.IUILayoutTabSearchConfig) => {
|
||||||
text = text.trim();
|
text = text.trim();
|
||||||
|
|
@ -890,6 +891,12 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
|
||||||
}
|
}
|
||||||
saveKeyList("keys", searchInputElement.value);
|
saveKeyList("keys", searchInputElement.value);
|
||||||
});
|
});
|
||||||
|
searchInputElement.addEventListener("keydown", (event) => {
|
||||||
|
electronUndo(event);
|
||||||
|
});
|
||||||
|
replaceInputElement.addEventListener("keydown", (event) => {
|
||||||
|
electronUndo(event);
|
||||||
|
});
|
||||||
addClearButton({
|
addClearButton({
|
||||||
inputElement: searchInputElement,
|
inputElement: searchInputElement,
|
||||||
right: 8,
|
right: 8,
|
||||||
|
|
@ -914,7 +921,7 @@ export const openSearchEditor = (options: {
|
||||||
id?: string,
|
id?: string,
|
||||||
cb?: () => void
|
cb?: () => void
|
||||||
}) => {
|
}) => {
|
||||||
const currentRange = options.protyle.highlight.ranges[options.protyle.highlight.rangeIndex];
|
let currentRange = options.protyle.highlight.ranges[options.protyle.highlight.rangeIndex];
|
||||||
if (currentRange) {
|
if (currentRange) {
|
||||||
const rangeBlockElement = hasClosestBlock(currentRange.startContainer);
|
const rangeBlockElement = hasClosestBlock(currentRange.startContainer);
|
||||||
if (rangeBlockElement) {
|
if (rangeBlockElement) {
|
||||||
|
|
@ -928,12 +935,15 @@ export const openSearchEditor = (options: {
|
||||||
zoomInId: options.protyle.block.showAll ? options.protyle.block.id : undefined
|
zoomInId: options.protyle.block.showAll ? options.protyle.block.id : undefined
|
||||||
};
|
};
|
||||||
window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.protyle.block.rootID] = scrollAttr;
|
window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.protyle.block.rootID] = scrollAttr;
|
||||||
|
if (offset.start === offset.end) {
|
||||||
|
currentRange = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkFold(options.id, (zoomIn) => {
|
checkFold(options.id, (zoomIn) => {
|
||||||
openFileById({
|
openFileById({
|
||||||
app: options.protyle.app,
|
app: options.protyle.app,
|
||||||
id:options.id,
|
id: options.id,
|
||||||
action: currentRange ?
|
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_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]),
|
(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]),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue