mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
This commit is contained in:
parent
4d0c136a56
commit
7a632bb718
2 changed files with 18 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ export class Editor extends Model {
|
||||||
rootId: string,
|
rootId: string,
|
||||||
mode?: TEditorMode,
|
mode?: TEditorMode,
|
||||||
action?: TProtyleAction[],
|
action?: TProtyleAction[],
|
||||||
|
afterInitProtyle: (editor: Protyle) => void,
|
||||||
}) {
|
}) {
|
||||||
super({
|
super({
|
||||||
app: options.app,
|
app: options.app,
|
||||||
|
|
@ -39,6 +40,7 @@ export class Editor extends Model {
|
||||||
action?: TProtyleAction[]
|
action?: TProtyleAction[]
|
||||||
rootId: string,
|
rootId: string,
|
||||||
mode?: TEditorMode,
|
mode?: TEditorMode,
|
||||||
|
afterInitProtyle: (editor: Protyle) => void,
|
||||||
}) {
|
}) {
|
||||||
this.editor = new Protyle(this.app, this.element, {
|
this.editor = new Protyle(this.app, this.element, {
|
||||||
action: options.action || [],
|
action: options.action || [],
|
||||||
|
|
@ -60,6 +62,9 @@ export class Editor extends Model {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
setModelsHash();
|
setModelsHash();
|
||||||
/// #endif
|
/// #endif
|
||||||
|
if (options.afterInitProtyle) {
|
||||||
|
options.afterInitProtyle(editor);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// 需在 after 回调之前,否则不会聚焦 https://github.com/siyuan-note/siyuan/issues/5303
|
// 需在 after 回调之前,否则不会聚焦 https://github.com/siyuan-note/siyuan/issues/5303
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,19 @@ export const copyTab = (app: App, tab: Tab) => {
|
||||||
rootId: tab.model.editor.protyle.block.rootID,
|
rootId: tab.model.editor.protyle.block.rootID,
|
||||||
// https://github.com/siyuan-note/siyuan/issues/12150
|
// https://github.com/siyuan-note/siyuan/issues/12150
|
||||||
action: newAction,
|
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) {
|
} else if (tab.model instanceof Asset) {
|
||||||
model = new Asset({
|
model = new Asset({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue