From 4756557c17039a1fa0a00407f4f82d814608fb76 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 24 Nov 2024 17:06:27 +0800 Subject: [PATCH] :bug: https://github.com/siyuan-note/siyuan/issues/12679 --- app/src/util/highlightById.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts index 08f97f3b3..1fab1ff39 100644 --- a/app/src/util/highlightById.ts +++ b/app/src/util/highlightById.ts @@ -1,5 +1,5 @@ import {hasClosestBlock, hasClosestByAttribute} from "../protyle/util/hasClosest"; -import {getEditorRange} from "../protyle/util/selection"; +import {focusByRange, getEditorRange} from "../protyle/util/selection"; export const bgFade = (element: Element) => { element.classList.add("protyle-wysiwyg--hl"); @@ -56,7 +56,8 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal (blockElement.querySelector(".av__row--header").getAttribute("style")?.indexOf("transform") > -1 || blockElement.querySelector(".av__row--footer").getAttribute("style")?.indexOf("transform") > -1)) { return; } - + // 撤销时 br 插入删除会导致 rang 被修改 https://github.com/siyuan-note/siyuan/issues/12679 + const cloneRange = range.cloneRange(); const br2Element = document.createElement("br"); range.insertNode(br2Element); const editorElement = protyle.contentElement; @@ -71,6 +72,7 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal editorElement.scroll({top: scrollTop, behavior}); } br2Element.remove(); + focusByRange(cloneRange); return; } }