Vanessa 2023-12-09 12:09:46 +08:00
parent e14ca5799b
commit 73505073e6
12 changed files with 42 additions and 59 deletions

View file

@ -27,6 +27,7 @@ import {openDocHistory} from "../../history/doc";
import {openNewWindowById} from "../../window/openNewWindow";
import {genImportMenu} from "../../menus/navigation";
import {transferBlockRef} from "../../menus/block";
import {saveScroll} from "../scroll/saveScroll";
export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
hideTooltip();
@ -204,6 +205,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
label: window.siyuan.languages.openByNewWindow,
icon: "iconOpenWindow",
click() {
saveScroll(protyle);
openNewWindowById(protyle.block.rootID);
}
}).element);

View file

@ -39,6 +39,7 @@ import {insertHTML} from "./util/insertHTML";
import {avRender} from "./render/av/render";
import {focusBlock, getEditorRange} from "./util/selection";
import {hasClosestBlock} from "./util/hasClosest";
import {setStorageVal} from "./util/compatibility";
export class Protyle {
@ -196,7 +197,7 @@ export class Protyle {
setEmpty(app);
/// #else
if (this.protyle.model) {
this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false, false);
this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false);
}
/// #endif
}
@ -207,9 +208,11 @@ export class Protyle {
setEmpty(app);
/// #else
if (this.protyle.model) {
this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false, false);
this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false);
}
/// #endif
delete window.siyuan.storage[Constants.LOCAL_FILEPOSITION][this.protyle.block.rootID];
setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION]);
}
break;
}
@ -225,10 +228,10 @@ export class Protyle {
removeLoading(this.protyle);
return;
}
if (options.scrollAttr) {
if (options.rootId) {
getDocByScroll({
protyle: this.protyle,
scrollAttr: options.scrollAttr,
scrollAttr: window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.rootId],
mergedOptions,
cb: () => {
this.afterOnGet(mergedOptions);
@ -245,19 +248,10 @@ export class Protyle {
this.getDoc(mergedOptions);
return;
}
let scrollObj;
if (response.data.ial.scroll) {
try {
scrollObj = JSON.parse(response.data.ial.scroll.replace(/"/g, '"'));
} catch (e) {
scrollObj = undefined;
}
}
if (scrollObj) {
scrollObj.rootId = response.data.rootID;
if (window.siyuan.storage[Constants.LOCAL_FILEPOSITION][response.data.rootID]) {
getDocByScroll({
protyle: this.protyle,
scrollAttr: scrollObj,
scrollAttr: window.siyuan.storage[Constants.LOCAL_FILEPOSITION][response.data.rootID],
mergedOptions,
cb: () => {
this.afterOnGet(mergedOptions);

View file

@ -39,8 +39,8 @@ export const saveScroll = (protyle: IProtyle, getObject = false) => {
if (getObject) {
return attr;
}
window.siyuan.storage[Constants.LOCAL_FILEPOSITION][protyle.block.rootID] = JSON.stringify(attr);
setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION][protyle.block.rootID]);
window.siyuan.storage[Constants.LOCAL_FILEPOSITION][protyle.block.rootID] = attr;
setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION]);
};
export const getDocByScroll = (options: {

View file

@ -33,7 +33,7 @@ export const onGet = (options: {
if (options.data.code === 1) {
// 其他报错
if (options.protyle.model) {
options.protyle.model.parent.parent.removeTab(options.protyle.model.parent.id, false, false);
options.protyle.model.parent.parent.removeTab(options.protyle.model.parent.id, false);
} else {
options.protyle.element.innerHTML = `<div class="ft__smaller ft__secondary b3-form__space--small" contenteditable="false">${window.siyuan.languages.refExpired}</div>`;
}