mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
f85b5d6740
commit
11adc35e10
13 changed files with 136 additions and 64 deletions
|
|
@ -3,6 +3,7 @@ import {Tab} from "../layout/Tab";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {setPanelFocus} from "../layout/util";
|
import {setPanelFocus} from "../layout/util";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
|
import {setModelsHash} from "../window/setHeader";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import {webViewerLoad} from "./pdf/viewer";
|
import {webViewerLoad} from "./pdf/viewer";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
@ -497,6 +498,7 @@ export class Asset extends Model {
|
||||||
this.element, this.pdfPage, this.pdfId);
|
this.element, this.pdfPage, this.pdfId);
|
||||||
this.element.setAttribute("data-loading", "true");
|
this.element.setAttribute("data-loading", "true");
|
||||||
}
|
}
|
||||||
|
setModelsHash();
|
||||||
}, Constants.TIMEOUT_BLOCKLOAD);
|
}, Constants.TIMEOUT_BLOCKLOAD);
|
||||||
/// #endif
|
/// #endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2467,20 +2467,7 @@ function webViewerResize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerHashchange(evt) {
|
function webViewerHashchange(evt) {
|
||||||
const hash = evt.hash;
|
|
||||||
if (!hash) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// NOTE
|
// NOTE
|
||||||
const pdfInstance = getPdfInstance(evt.source)
|
|
||||||
if (!pdfInstance) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!pdfInstance.isInitialViewSet) {
|
|
||||||
pdfInstance.initialBookmark = hash;
|
|
||||||
} else if (!pdfInstance.pdfHistory?.popStateInProgress) {
|
|
||||||
pdfInstance.pdfLinkService.setHash(hash);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ import {Model} from "../layout/Model";
|
||||||
import {disabledProtyle} from "../protyle/util/onGet";
|
import {disabledProtyle} from "../protyle/util/onGet";
|
||||||
import {setPadding} from "../protyle/ui/initUI";
|
import {setPadding} from "../protyle/ui/initUI";
|
||||||
import {getAllModels} from "../layout/getAll";
|
import {getAllModels} from "../layout/getAll";
|
||||||
|
/// #if !BROWSER
|
||||||
|
import {setModelsHash} from "../window/setHeader";
|
||||||
|
/// #endif
|
||||||
import {countBlockWord} from "../layout/status";
|
import {countBlockWord} from "../layout/status";
|
||||||
|
|
||||||
export class Editor extends Model {
|
export class Editor extends Model {
|
||||||
|
|
@ -62,6 +65,9 @@ export class Editor extends Model {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
countBlockWord([], editor.protyle.block.rootID);
|
countBlockWord([], editor.protyle.block.rootID);
|
||||||
|
/// #if !BROWSER
|
||||||
|
setModelsHash();
|
||||||
|
/// #endif
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// 需在 after 回调之前,否则不会聚焦 https://github.com/siyuan-note/siyuan/issues/5303
|
// 需在 after 回调之前,否则不会聚焦 https://github.com/siyuan-note/siyuan/issues/5303
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import {focusBlock, focusByRange} from "../protyle/util/selection";
|
||||||
import {onGet} from "../protyle/util/onGet";
|
import {onGet} from "../protyle/util/onGet";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {shell} from "electron";
|
import {shell} from "electron";
|
||||||
import {BrowserWindow} from "@electron/remote";
|
import {BrowserWindow, getCurrentWindow} from "@electron/remote";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {pushBack} from "../util/backForward";
|
import {pushBack} from "../util/backForward";
|
||||||
import {Asset} from "../asset";
|
import {Asset} from "../asset";
|
||||||
|
|
@ -158,31 +158,31 @@ export const openFile = (options: IOpenFileOptions) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let hasOpen = false;
|
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
// https://github.com/siyuan-note/siyuan/issues/7491
|
// https://github.com/siyuan-note/siyuan/issues/7491
|
||||||
BrowserWindow.getAllWindows().find((item) => {
|
const currentWindowId = getCurrentWindow().id
|
||||||
const json = getSearch("json", new URL(item.webContents.getURL()).search);
|
const hasMatch = BrowserWindow.getAllWindows().find(item => {
|
||||||
if (json) {
|
if (item.id === currentWindowId) {
|
||||||
const jsonObj = JSON.parse(json);
|
return;
|
||||||
if ((jsonObj.children.rootId && jsonObj.children.rootId === options.rootID) ||
|
}
|
||||||
(jsonObj.children.path && jsonObj.children.path === options.assetPath)) {
|
const ids = decodeURIComponent(new URL(item.webContents.getURL()).hash.substring(1)).split(Constants.ZWSP);
|
||||||
item.focus();
|
if (ids.includes(options.rootID) || ids.includes(options.assetPath)) {
|
||||||
|
let execJS = `window.newWindow.switchTabById("${options.rootID || options.assetPath}");`
|
||||||
if (options.assetPath) {
|
if (options.assetPath) {
|
||||||
item.webContents.executeJavaScript(`window.newWindow.positionPDF("${options.assetPath}", ${typeof options.page === "number" ? options.page : `"${options.page}"`})`);
|
execJS += `window.newWindow.positionPDF("${options.assetPath}", ${typeof options.page === "number" ? options.page : `"${options.page}"`})`
|
||||||
}
|
}
|
||||||
hasOpen = true;
|
item.focus();
|
||||||
return true;
|
item.webContents.executeJavaScript(execJS);
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/// #endif
|
|
||||||
if (hasOpen) {
|
|
||||||
if (options.afterOpen) {
|
if (options.afterOpen) {
|
||||||
options.afterOpen();
|
options.afterOpen();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (hasMatch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/// #endif
|
||||||
|
|
||||||
let wnd: Wnd = undefined;
|
let wnd: Wnd = undefined;
|
||||||
// 获取光标所在 tab
|
// 获取光标所在 tab
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import {Constants} from "../constants";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {webFrame, ipcRenderer} from "electron";
|
import {webFrame, ipcRenderer} from "electron";
|
||||||
import {getCurrentWindow} from "@electron/remote";
|
import {getCurrentWindow} from "@electron/remote";
|
||||||
import {setTabPosition} from "../window/setHeader";
|
import {setModelsHash, setTabPosition} from "../window/setHeader";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {Search} from "../search";
|
import {Search} from "../search";
|
||||||
import {showMessage} from "../dialog/message";
|
import {showMessage} from "../dialog/message";
|
||||||
|
|
@ -228,6 +228,7 @@ export class Wnd {
|
||||||
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});
|
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});
|
||||||
it.querySelector("li[data-clone='true']").remove();
|
it.querySelector("li[data-clone='true']").remove();
|
||||||
wnd.switchTab(oldTab.headElement);
|
wnd.switchTab(oldTab.headElement);
|
||||||
|
getCurrentWindow().focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
@ -334,6 +335,7 @@ export class Wnd {
|
||||||
JSONToCenter(tabData, this);
|
JSONToCenter(tabData, this);
|
||||||
oldTab = this.children[this.children.length - 1];
|
oldTab = this.children[this.children.length - 1];
|
||||||
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});
|
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});
|
||||||
|
getCurrentWindow().focus();
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
if (!oldTab) {
|
if (!oldTab) {
|
||||||
|
|
@ -552,6 +554,7 @@ export class Wnd {
|
||||||
}
|
}
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
setTabPosition();
|
setTabPosition();
|
||||||
|
setModelsHash();
|
||||||
/// #endif
|
/// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -689,9 +692,6 @@ export class Wnd {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/// #if !BROWSER
|
|
||||||
setTabPosition();
|
|
||||||
/// #endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (item.headElement) {
|
if (item.headElement) {
|
||||||
|
|
@ -746,6 +746,7 @@ export class Wnd {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
webFrame.clearCache();
|
webFrame.clearCache();
|
||||||
getCurrentWindow().webContents.session.clearCache();
|
getCurrentWindow().webContents.session.clearCache();
|
||||||
|
setTabPosition();
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,12 +64,12 @@ export const getAllModels = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAllTabs = () => {
|
export const getAllTabs = () => {
|
||||||
const models: Tab[] = [];
|
const tabs: Tab[] = [];
|
||||||
const getTabs = (layout: Layout) => {
|
const getTabs = (layout: Layout) => {
|
||||||
for (let i = 0; i < layout.children.length; i++) {
|
for (let i = 0; i < layout.children.length; i++) {
|
||||||
const item = layout.children[i];
|
const item = layout.children[i];
|
||||||
if (item instanceof Tab) {
|
if (item instanceof Tab) {
|
||||||
models.push(item);
|
tabs.push(item);
|
||||||
} else {
|
} else {
|
||||||
getTabs(item as Layout);
|
getTabs(item as Layout);
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +79,7 @@ export const getAllTabs = () => {
|
||||||
if (window.siyuan.layout.centerLayout) {
|
if (window.siyuan.layout.centerLayout) {
|
||||||
getTabs(window.siyuan.layout.centerLayout);
|
getTabs(window.siyuan.layout.centerLayout);
|
||||||
}
|
}
|
||||||
return models;
|
return tabs;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAllDocks = () => {
|
export const getAllDocks = () => {
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ const JSONToDock = (json: any) => {
|
||||||
window.siyuan.layout.bottomDock = new Dock({position: "Bottom", data: json.bottom});
|
window.siyuan.layout.bottomDock = new Dock({position: "Bottom", data: json.bottom});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model, isStart = false) => {
|
export const JSONToCenter = (json: ILayoutJSON, layout?: Layout | Wnd | Tab | Model, isStart = false) => {
|
||||||
let child: Layout | Wnd | Tab | Model;
|
let child: Layout | Wnd | Tab | Model;
|
||||||
if (json.instance === "Layout") {
|
if (json.instance === "Layout") {
|
||||||
if (!layout) {
|
if (!layout) {
|
||||||
|
|
@ -309,7 +309,7 @@ export const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model, isS
|
||||||
tab: (layout as Tab),
|
tab: (layout as Tab),
|
||||||
blockId: json.blockId,
|
blockId: json.blockId,
|
||||||
rootId: json.rootId,
|
rootId: json.rootId,
|
||||||
type: json.type,
|
type: json.type as "pin" | "local",
|
||||||
}));
|
}));
|
||||||
} else if (json.instance === "Bookmark") {
|
} else if (json.instance === "Bookmark") {
|
||||||
(layout as Tab).addModel(new Bookmark((layout as Tab)));
|
(layout as Tab).addModel(new Bookmark((layout as Tab)));
|
||||||
|
|
@ -322,13 +322,13 @@ export const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model, isS
|
||||||
tab: (layout as Tab),
|
tab: (layout as Tab),
|
||||||
blockId: json.blockId,
|
blockId: json.blockId,
|
||||||
rootId: json.rootId,
|
rootId: json.rootId,
|
||||||
type: json.type
|
type: json.type as "pin" | "local" | "global",
|
||||||
}));
|
}));
|
||||||
} else if (json.instance === "Outline") {
|
} else if (json.instance === "Outline") {
|
||||||
(layout as Tab).addModel(new Outline({
|
(layout as Tab).addModel(new Outline({
|
||||||
tab: (layout as Tab),
|
tab: (layout as Tab),
|
||||||
blockId: json.blockId,
|
blockId: json.blockId,
|
||||||
type: json.type
|
type: json.type as "pin" | "local",
|
||||||
}));
|
}));
|
||||||
} else if (json.instance === "Tag") {
|
} else if (json.instance === "Tag") {
|
||||||
(layout as Tab).addModel(new Tag((layout as Tab)));
|
(layout as Tab).addModel(new Tag((layout as Tab)));
|
||||||
|
|
@ -347,7 +347,7 @@ export const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model, isS
|
||||||
if (Array.isArray(json.children)) {
|
if (Array.isArray(json.children)) {
|
||||||
json.children.forEach((item: any, index: number) => {
|
json.children.forEach((item: any, index: number) => {
|
||||||
JSONToCenter(item, layout ? child : window.siyuan.layout.layout, isStart);
|
JSONToCenter(item, layout ? child : window.siyuan.layout.layout, isStart);
|
||||||
if (item.instance === "Tab" && index === json.children.length - 1) {
|
if (item.instance === "Tab" && index === (json.children as ILayoutJSON[]).length - 1) {
|
||||||
const activeTabElement = (child as Wnd).headersElement.querySelector('[data-init-active="true"]') as HTMLElement;
|
const activeTabElement = (child as Wnd).headersElement.querySelector('[data-init-active="true"]') as HTMLElement;
|
||||||
if (activeTabElement) {
|
if (activeTabElement) {
|
||||||
if (window.siyuan.config.fileTree.closeTabsOnStart && isStart &&
|
if (window.siyuan.config.fileTree.closeTabsOnStart && isStart &&
|
||||||
|
|
@ -832,7 +832,7 @@ export const newCenterEmptyTab = () => {
|
||||||
callback(tab: Tab) {
|
callback(tab: Tab) {
|
||||||
tab.panelElement.addEventListener("click", (event) => {
|
tab.panelElement.addEventListener("click", (event) => {
|
||||||
let target = event.target as HTMLElement;
|
let target = event.target as HTMLElement;
|
||||||
while (target && !target.isEqualNode( tab.panelElement)) {
|
while (target && !target.isEqualNode(tab.panelElement)) {
|
||||||
if (target.id === "editorEmptySearch") {
|
if (target.id === "editorEmptySearch") {
|
||||||
openSearch(window.siyuan.config.keymap.general.globalSearch.custom);
|
openSearch(window.siyuan.config.keymap.general.globalSearch.custom);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
@ -852,22 +852,22 @@ export const newCenterEmptyTab = () => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
}else if (target.id === "editorEmptyHistory") {
|
} else if (target.id === "editorEmptyHistory") {
|
||||||
openHistory();
|
openHistory();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
}else if (target.id === "editorEmptyFile") {
|
} else if (target.id === "editorEmptyFile") {
|
||||||
newFile(undefined, undefined, undefined, true);
|
newFile(undefined, undefined, undefined, true);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
}else if (target.id === "editorEmptyNewNotebook") {
|
} else if (target.id === "editorEmptyNewNotebook") {
|
||||||
newNotebook();
|
newNotebook();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
}else if (target.id === "editorEmptyHelp") {
|
} else if (target.id === "editorEmptyHelp") {
|
||||||
mountHelp();
|
mountHelp();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
||||||
24
app/src/types/index.d.ts
vendored
24
app/src/types/index.d.ts
vendored
|
|
@ -50,6 +50,7 @@ interface Window {
|
||||||
|
|
||||||
newWindow: {
|
newWindow: {
|
||||||
positionPDF(pathStr: string, page: string | number): void
|
positionPDF(pathStr: string, page: string | number): void
|
||||||
|
switchTabById(id: string): void
|
||||||
}
|
}
|
||||||
|
|
||||||
Protyle: import("../protyle/method").default
|
Protyle: import("../protyle/method").default
|
||||||
|
|
@ -271,6 +272,29 @@ interface IObject {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare interface ILayoutJSON extends ILayoutOptions {
|
||||||
|
instance?: string,
|
||||||
|
width?: string,
|
||||||
|
height?: string,
|
||||||
|
title?: string,
|
||||||
|
lang?: string
|
||||||
|
docIcon?: string
|
||||||
|
page?: string
|
||||||
|
path?: string
|
||||||
|
blockId?: string
|
||||||
|
icon?: string
|
||||||
|
rootId?: string
|
||||||
|
active?: boolean
|
||||||
|
pin?: boolean
|
||||||
|
data?: {
|
||||||
|
cardType: TCardType,
|
||||||
|
id: string,
|
||||||
|
title?: string
|
||||||
|
}
|
||||||
|
config?: ISearchOption
|
||||||
|
children?: ILayoutJSON[] | ILayoutJSON
|
||||||
|
}
|
||||||
|
|
||||||
declare interface IDockTab {
|
declare interface IDockTab {
|
||||||
type: TDockType;
|
type: TDockType;
|
||||||
size: { width: number, height: number }
|
size: { width: number, height: number }
|
||||||
|
|
|
||||||
37
app/src/window/global/function.ts
Normal file
37
app/src/window/global/function.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
import {getAllTabs} from "../../layout/getAll";
|
||||||
|
import {Asset} from "../../asset";
|
||||||
|
import {Editor} from "../../editor";
|
||||||
|
|
||||||
|
export const positionPDF = (pathStr: string, page: string | number) => {
|
||||||
|
getAllTabs().forEach((tab) => {
|
||||||
|
if (tab.model instanceof Asset && tab.model.pdfObject && tab.model.path === pathStr) {
|
||||||
|
tab.parent.switchTab(tab.headElement);
|
||||||
|
tab.model.goToPage(page);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const switchTabById = (id: string) => {
|
||||||
|
getAllTabs().find((tab) => {
|
||||||
|
if (!tab.model) {
|
||||||
|
const initTab = tab.headElement.getAttribute("data-initdata");
|
||||||
|
if (initTab) {
|
||||||
|
const initTabData = JSON.parse(initTab);
|
||||||
|
if (initTabData.rootId === id) {
|
||||||
|
tab.parent.switchTab(tab.headElement);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (tab.model instanceof Editor) {
|
||||||
|
if (tab.model.editor.protyle.block.rootID === id) {
|
||||||
|
tab.parent.switchTab(tab.headElement);
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} else if (tab.model instanceof Asset) {
|
||||||
|
if (tab.model.path === id) {
|
||||||
|
tab.parent.switchTab(tab.headElement);
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
import {getAllTabs} from "../../layout/getAll";
|
|
||||||
import {Asset} from "../../asset";
|
|
||||||
|
|
||||||
export const positionPDF = (pathStr: string, page: string | number) => {
|
|
||||||
getAllTabs().forEach((tab) => {
|
|
||||||
if (tab.model instanceof Asset && tab.model.pdfObject && tab.model.path === pathStr) {
|
|
||||||
tab.parent.switchTab(tab.headElement);
|
|
||||||
tab.model.goToPage(page);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
@ -20,7 +20,7 @@ import {initMessage} from "../dialog/message";
|
||||||
import {getAllTabs} from "../layout/getAll";
|
import {getAllTabs} from "../layout/getAll";
|
||||||
import {getLocalStorage} from "../protyle/util/compatibility";
|
import {getLocalStorage} from "../protyle/util/compatibility";
|
||||||
import {init} from "../window/init";
|
import {init} from "../window/init";
|
||||||
import {positionPDF} from "./global/positionPDF";
|
import {positionPDF, switchTabById} from "./global/function";
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -145,5 +145,6 @@ new App();
|
||||||
|
|
||||||
// 再次点击新窗口已打开的 PDF 时,需进行定位
|
// 再次点击新窗口已打开的 PDF 时,需进行定位
|
||||||
window.newWindow = {
|
window.newWindow = {
|
||||||
positionPDF: positionPDF
|
positionPDF: positionPDF,
|
||||||
|
switchTabById: switchTabById
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ export const init = () => {
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
window.siyuan.layout.centerLayout = window.siyuan.layout.layout;
|
window.siyuan.layout.centerLayout = window.siyuan.layout.layout;
|
||||||
|
|
||||||
});
|
});
|
||||||
initStatus(true);
|
initStatus(true);
|
||||||
initWindow();
|
initWindow();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@ import {isWindow} from "../util/functions";
|
||||||
import {Wnd} from "../layout/Wnd";
|
import {Wnd} from "../layout/Wnd";
|
||||||
import {getCurrentWindow} from "@electron/remote";
|
import {getCurrentWindow} from "@electron/remote";
|
||||||
import {Layout} from "../layout";
|
import {Layout} from "../layout";
|
||||||
|
import {getAllTabs} from "../layout/getAll";
|
||||||
|
import {Editor} from "../editor";
|
||||||
|
import {Asset} from "../asset";
|
||||||
|
import {Constants} from "../constants";
|
||||||
|
|
||||||
const getAllWnds = (layout: Layout, wnds: Wnd[]) => {
|
const getAllWnds = (layout: Layout, wnds: Wnd[]) => {
|
||||||
for (let i = 0; i < layout.children.length; i++) {
|
for (let i = 0; i < layout.children.length; i++) {
|
||||||
|
|
@ -50,3 +54,25 @@ export const setTabPosition = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const setModelsHash = () => {
|
||||||
|
if (!isWindow()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let hash = ""
|
||||||
|
getAllTabs().forEach(tab => {
|
||||||
|
if (!tab.model) {
|
||||||
|
const initTab = tab.headElement.getAttribute("data-initdata");
|
||||||
|
if (initTab) {
|
||||||
|
const initTabData = JSON.parse(initTab);
|
||||||
|
hash += initTabData.rootId + Constants.ZWSP
|
||||||
|
}
|
||||||
|
} else if (tab.model instanceof Editor) {
|
||||||
|
hash += tab.model.editor.protyle.block.rootID + Constants.ZWSP
|
||||||
|
} else if (tab.model instanceof Asset) {
|
||||||
|
hash += tab.model.path + Constants.ZWSP
|
||||||
|
}
|
||||||
|
})
|
||||||
|
window.location.hash = hash
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue