From 7a632bb718d5ea4427409f5419dc28ba2b6815a7 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 4 Apr 2025 18:33:24 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/13851 --- app/src/editor/index.ts | 5 +++++ app/src/layout/tabUtil.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/src/editor/index.ts b/app/src/editor/index.ts index 91725b981..ba03a77a5 100644 --- a/app/src/editor/index.ts +++ b/app/src/editor/index.ts @@ -21,6 +21,7 @@ export class Editor extends Model { rootId: string, mode?: TEditorMode, action?: TProtyleAction[], + afterInitProtyle: (editor: Protyle) => void, }) { super({ app: options.app, @@ -39,6 +40,7 @@ export class Editor extends Model { action?: TProtyleAction[] rootId: string, mode?: TEditorMode, + afterInitProtyle: (editor: Protyle) => void, }) { this.editor = new Protyle(this.app, this.element, { action: options.action || [], @@ -60,6 +62,9 @@ export class Editor extends Model { /// #if !BROWSER setModelsHash(); /// #endif + if (options.afterInitProtyle) { + options.afterInitProtyle(editor); + } }, }); // 需在 after 回调之前,否则不会聚焦 https://github.com/siyuan-note/siyuan/issues/5303 diff --git a/app/src/layout/tabUtil.ts b/app/src/layout/tabUtil.ts index dce287d71..a5d49533a 100644 --- a/app/src/layout/tabUtil.ts +++ b/app/src/layout/tabUtil.ts @@ -267,6 +267,19 @@ export const copyTab = (app: App, tab: Tab) => { rootId: tab.model.editor.protyle.block.rootID, // https://github.com/siyuan-note/siyuan/issues/12150 action: newAction, + afterInitProtyle(editor) { + // https://github.com/siyuan-note/siyuan/issues/13851 + if (tab.model instanceof Editor) { + const copyResizeTopElement = tab.model.editor.protyle.wysiwyg.element.querySelector("[data-resize-top]") + if (copyResizeTopElement) { + const newElement = editor.protyle.wysiwyg.element.querySelector(`[data-node-id="${copyResizeTopElement.getAttribute("data-node-id")}"]`) + if (newElement) { + newElement.scrollIntoView(); + editor.protyle.contentElement.scrollTop += newElement.getBoundingClientRect().top - parseInt(copyResizeTopElement.getAttribute("data-resize-top")); + } + } + } + } }); } else if (tab.model instanceof Asset) { model = new Asset({