Vanessa 2024-11-24 17:06:27 +08:00
parent 30f65e6c8e
commit 4756557c17

View file

@ -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;
}
}