mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-14 03:04:21 +01:00
This commit is contained in:
parent
8d6c422af0
commit
ef03fd4cb3
11 changed files with 55 additions and 76 deletions
|
|
@ -385,17 +385,17 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IMod
|
|||
preventScroll(editor.editor.protyle);
|
||||
editor.editor.protyle.observerLoad?.disconnect();
|
||||
if (options.action?.includes(Constants.CB_GET_HL)) {
|
||||
highlightById(editor.editor.protyle, options.id, "top");
|
||||
highlightById(editor.editor.protyle, options.id, "start");
|
||||
} else if (options.action?.includes(Constants.CB_GET_FOCUS)) {
|
||||
if (nodeElement) {
|
||||
const newRange = focusBlock(nodeElement, undefined, !options.action?.includes(Constants.CB_GET_OUTLINE));
|
||||
if (newRange) {
|
||||
editor.editor.protyle.toolbar.range = newRange;
|
||||
}
|
||||
scrollCenter(editor.editor.protyle, nodeElement, {position: "top"});
|
||||
scrollCenter(editor.editor.protyle);
|
||||
editor.editor.protyle.observerLoad = new ResizeObserver(() => {
|
||||
if (document.contains(nodeElement)) {
|
||||
scrollCenter(editor.editor.protyle, nodeElement, {position: "top"});
|
||||
scrollCenter(editor.editor.protyle);
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
|
|
@ -407,9 +407,7 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IMod
|
|||
} else if (editor.editor.protyle.toolbar.range) {
|
||||
nodeElement = hasClosestBlock(editor.editor.protyle.toolbar.range.startContainer) as Element;
|
||||
focusByRange(editor.editor.protyle.toolbar.range);
|
||||
if (nodeElement) {
|
||||
scrollCenter(editor.editor.protyle, nodeElement);
|
||||
}
|
||||
scrollCenter(editor.editor.protyle);
|
||||
}
|
||||
}
|
||||
pushBack(editor.editor.protyle, editor.editor.protyle.toolbar.range);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue