mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-21 19:41:05 +08:00
This commit is contained in:
parent
fbc357f3c4
commit
a03ef95431
@ -181,10 +181,7 @@ const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model) => {
|
|||||||
child.element.classList.remove("fn__flex-1");
|
child.element.classList.remove("fn__flex-1");
|
||||||
child.element.style.height = json.height;
|
child.element.style.height = json.height;
|
||||||
}
|
}
|
||||||
} else if (json.instance === "Tab" && (
|
} else if (json.instance === "Tab") {
|
||||||
(window.siyuan.config.fileTree.closeTabsOnStart && json.pin) ||
|
|
||||||
!window.siyuan.config.fileTree.closeTabsOnStart)
|
|
||||||
) {
|
|
||||||
if (!json.title) {
|
if (!json.title) {
|
||||||
child = newCenterEmptyTab();
|
child = newCenterEmptyTab();
|
||||||
} else {
|
} else {
|
||||||
@ -208,14 +205,14 @@ const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model) => {
|
|||||||
child.headElement.setAttribute("data-init-active", "true");
|
child.headElement.setAttribute("data-init-active", "true");
|
||||||
}
|
}
|
||||||
(layout as Wnd).addTab(child);
|
(layout as Wnd).addTab(child);
|
||||||
} else if (json.instance === "Editor" && json.blockId && layout) {
|
} else if (json.instance === "Editor" && json.blockId) {
|
||||||
(layout as Tab).addModel(new Editor({
|
(layout as Tab).addModel(new Editor({
|
||||||
tab: (layout as Tab),
|
tab: (layout as Tab),
|
||||||
blockId: json.blockId,
|
blockId: json.blockId,
|
||||||
mode: json.mode,
|
mode: json.mode,
|
||||||
action: [json.action]
|
action: [json.action]
|
||||||
}));
|
}));
|
||||||
} else if (json.instance === "Asset" && layout) {
|
} else if (json.instance === "Asset") {
|
||||||
(layout as Tab).addModel(new Asset({
|
(layout as Tab).addModel(new Asset({
|
||||||
tab: (layout as Tab),
|
tab: (layout as Tab),
|
||||||
path: json.path,
|
path: json.path,
|
||||||
@ -233,22 +230,22 @@ const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model) => {
|
|||||||
(layout as Tab).addModel(new Files({
|
(layout as Tab).addModel(new Files({
|
||||||
tab: (layout as Tab),
|
tab: (layout as Tab),
|
||||||
}));
|
}));
|
||||||
} else if (json.instance === "Graph" && layout) {
|
} else if (json.instance === "Graph") {
|
||||||
(layout as Tab).addModel(new Graph({
|
(layout as Tab).addModel(new Graph({
|
||||||
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
|
||||||
}));
|
}));
|
||||||
} else if (json.instance === "Outline" && layout) {
|
} 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
|
||||||
}));
|
}));
|
||||||
} else if (json.instance === "Tag" && layout) {
|
} else if (json.instance === "Tag") {
|
||||||
(layout as Tab).addModel(new Tag((layout as Tab)));
|
(layout as Tab).addModel(new Tag((layout as Tab)));
|
||||||
} else if (json.instance === "Search" && layout) {
|
} else if (json.instance === "Search") {
|
||||||
(layout as Tab).addModel(new Search({
|
(layout as Tab).addModel(new Search({
|
||||||
tab: (layout as Tab),
|
tab: (layout as Tab),
|
||||||
text: json.text
|
text: json.text
|
||||||
@ -275,10 +272,41 @@ const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model) => {
|
|||||||
export const JSONToLayout = () => {
|
export const JSONToLayout = () => {
|
||||||
JSONToCenter(window.siyuan.config.uiLayout.layout);
|
JSONToCenter(window.siyuan.config.uiLayout.layout);
|
||||||
JSONToDock(window.siyuan.config.uiLayout);
|
JSONToDock(window.siyuan.config.uiLayout);
|
||||||
// 启动时不打开页签且没有钉住的页签,需要添加空白页
|
const allModels = getAllModels();
|
||||||
if (window.siyuan.layout.centerLayout.children[0].children.length === 0) {
|
// 启动时不打开页签,需要移除没有钉住的页签
|
||||||
(window.siyuan.layout.centerLayout.children[0] as Wnd).addTab(newCenterEmptyTab());
|
if (window.siyuan.config.fileTree.closeTabsOnStart) {
|
||||||
|
allModels.editor.forEach(item => {
|
||||||
|
if (item.parent.headElement && !item.parent.headElement.classList.contains("item--pin")) {
|
||||||
|
item.parent.parent.removeTab(item.parent.id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
allModels.outline.forEach(item => {
|
||||||
|
if (item.parent.headElement && !item.parent.headElement.classList.contains("item--pin")) {
|
||||||
|
item.parent.parent.removeTab(item.parent.id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
allModels.search.forEach(item => {
|
||||||
|
if (item.parent.headElement && !item.parent.headElement.classList.contains("item--pin")) {
|
||||||
|
item.parent.parent.removeTab(item.parent.id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
allModels.asset.forEach(item => {
|
||||||
|
if (item.parent.headElement && !item.parent.headElement.classList.contains("item--pin")) {
|
||||||
|
item.parent.parent.removeTab(item.parent.id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
allModels.graph.forEach(item => {
|
||||||
|
if (item.parent.headElement && !item.parent.headElement.classList.contains("item--pin")) {
|
||||||
|
item.parent.parent.removeTab(item.parent.id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
allModels.backlinks.forEach(item => {
|
||||||
|
if (item.parent.headElement && !item.parent.headElement.classList.contains("item--pin")) {
|
||||||
|
item.parent.parent.removeTab(item.parent.id);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getAllModels().editor.find(item => {
|
getAllModels().editor.find(item => {
|
||||||
if (item.headElement.classList.contains("item--focus")) {
|
if (item.headElement.classList.contains("item--focus")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user