Vanessa 2025-12-20 12:06:13 +08:00
parent 319db401c2
commit 29569e0075
2 changed files with 14 additions and 3 deletions

View file

@ -398,19 +398,29 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IMod
}
if (options.action?.includes(Constants.CB_GET_FOCUS)) {
if (nodeElement) {
let scrollTop: number;
if (options.action.includes(Constants.CB_GET_SEARCH)) {
const scrollAttr = window.siyuan.storage[Constants.LOCAL_FILEPOSITION][editor.editor.protyle.block.rootID];
focusByOffset(nodeElement, scrollAttr.focusStart, scrollAttr.focusEnd);
scrollTop = scrollAttr.scrollTop;
} else {
const newRange = focusBlock(nodeElement, undefined, !options.action?.includes(Constants.CB_GET_OUTLINE));
if (newRange) {
editor.editor.protyle.toolbar.range = newRange;
}
}
scrollCenter(editor.editor.protyle, (editor.editor.protyle.disabled || options.scrollPosition) ? nodeElement : null, options.scrollPosition);
if (typeof scrollTop === "number") {
editor.editor.protyle.contentElement.scrollTop = scrollTop;
} else {
scrollCenter(editor.editor.protyle, (editor.editor.protyle.disabled || options.scrollPosition) ? nodeElement : null, options.scrollPosition);
}
editor.editor.protyle.observerLoad = new ResizeObserver(() => {
if (document.contains(nodeElement)) {
scrollCenter(editor.editor.protyle, (editor.editor.protyle.disabled || options.scrollPosition) ? nodeElement : null, options.scrollPosition);
if (typeof scrollTop === "number") {
editor.editor.protyle.contentElement.scrollTop = scrollTop;
} else {
scrollCenter(editor.editor.protyle, (editor.editor.protyle.disabled || options.scrollPosition) ? nodeElement : null, options.scrollPosition);
}
}
});
setTimeout(() => {