diff --git a/app/src/search/util.ts b/app/src/search/util.ts index dc1cf3e08..fad2e1625 100644 --- a/app/src/search/util.ts +++ b/app/src/search/util.ts @@ -47,6 +47,7 @@ import {saveKeyList, toggleAssetHistory, toggleReplaceHistory, toggleSearchHisto import {highlightById} from "../util/highlightById"; import {getSelectionOffset} from "../protyle/util/selection"; import {electronUndo} from "../protyle/undo"; +import {getContenteditableElement} from "../protyle/wysiwyg/getBlock"; export const openGlobalSearch = (app: App, text: string, replace: boolean, searchData?: Config.IUILayoutTabSearchConfig) => { text = text.trim(); @@ -934,7 +935,7 @@ export const openSearchEditor = (options: { const rangeBlockElement = hasClosestBlock(currentRange.startContainer); if (rangeBlockElement) { options.id = rangeBlockElement.getAttribute("data-node-id"); - const offset = getSelectionOffset(rangeBlockElement, null, options.protyle.highlight.ranges[options.protyle.highlight.rangeIndex]); + const offset = getSelectionOffset(getContenteditableElement(rangeBlockElement), null, options.protyle.highlight.ranges[options.protyle.highlight.rangeIndex]); const scrollAttr: IScrollAttr = { rootId: options.protyle.block.rootID, focusId: options.id,