mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-08 17:58:50 +01:00
This commit is contained in:
parent
319db401c2
commit
29569e0075
2 changed files with 14 additions and 3 deletions
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -940,7 +940,8 @@ export const openSearchEditor = (options: {
|
|||
focusId: options.id,
|
||||
focusStart: offset.start,
|
||||
focusEnd: offset.end,
|
||||
zoomInId: options.protyle.block.showAll ? options.protyle.block.id : undefined
|
||||
zoomInId: options.protyle.block.showAll ? options.protyle.block.id : undefined,
|
||||
scrollTop: options.protyle.contentElement.scrollTop,
|
||||
};
|
||||
window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.protyle.block.rootID] = scrollAttr;
|
||||
if (offset.start === offset.end) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue