mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 15:58:49 +01:00
This commit is contained in:
parent
318e570343
commit
397da9d57d
4 changed files with 44 additions and 2 deletions
|
|
@ -11,10 +11,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
&__center {
|
||||
min-width: 148px;
|
||||
}
|
||||
|
||||
&__dockl,
|
||||
&__dockr,
|
||||
&__dockb {
|
||||
transition: var(--b3-width-transition);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
& > .layout__dockresize {
|
||||
|
|
@ -145,6 +150,7 @@
|
|||
width: 100%;
|
||||
background-color: var(--b3-theme-background);
|
||||
align-items: center;
|
||||
min-width: 204px;
|
||||
|
||||
.b3-list-item {
|
||||
width: 204px;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {exportLayout, JSONToLayout, resetLayout, resizeTopBar} from "../layout/util";
|
||||
import {adjustLayout, exportLayout, JSONToLayout, resetLayout, resizeTopBar} from "../layout/util";
|
||||
import {resizeTabs} from "../layout/tabUtil";
|
||||
import {setStorageVal} from "../protyle/util/compatibility";
|
||||
/// #if !BROWSER
|
||||
|
|
@ -126,6 +126,7 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
|||
window.siyuan.emojis = response.data as IEmoji[];
|
||||
try {
|
||||
JSONToLayout(app, isStart);
|
||||
adjustLayout();
|
||||
/// #if !BROWSER
|
||||
sendGlobalShortcut(app);
|
||||
/// #endif
|
||||
|
|
@ -145,6 +146,7 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
|||
window.addEventListener("resize", () => {
|
||||
window.clearTimeout(resizeTimeout);
|
||||
resizeTimeout = window.setTimeout(() => {
|
||||
adjustLayout();
|
||||
resizeTabs();
|
||||
resizeTopBar();
|
||||
}, 200);
|
||||
|
|
|
|||
|
|
@ -841,6 +841,7 @@ export const addResize = (obj: Layout | Wnd) => {
|
|||
documentSelf.ondragstart = null;
|
||||
documentSelf.onselectstart = null;
|
||||
documentSelf.onselect = null;
|
||||
adjustLayout(isWindow() ? window.siyuan.layout.centerLayout : undefined);
|
||||
resizeTabs();
|
||||
if (!isWindow()) {
|
||||
window.siyuan.layout.leftDock.setSize();
|
||||
|
|
@ -864,3 +865,34 @@ export const addResize = (obj: Layout | Wnd) => {
|
|||
obj.element.insertAdjacentElement("beforebegin", resizeElement);
|
||||
resizeWnd(resizeElement, obj.resize);
|
||||
};
|
||||
|
||||
export const adjustLayout = (layout: Layout = window.siyuan.layout.centerLayout.parent) => {
|
||||
layout.children.forEach((item: Layout | Wnd) => {
|
||||
item.element.style.maxWidth = "";
|
||||
if (!item.element.style.width && !item.element.classList.contains("layout__center")) {
|
||||
item.element.style.minWidth = "8px";
|
||||
} else {
|
||||
item.element.style.minWidth = "";
|
||||
}
|
||||
});
|
||||
let lastItem: HTMLElement
|
||||
while (layout.element.scrollWidth > layout.element.clientWidth) {
|
||||
layout.children.find((item: Layout | Wnd) => {
|
||||
if (item.element.style.width && item.element.style.width !== "0px") {
|
||||
item.element.style.maxWidth = Math.max(Math.min(item.element.clientWidth, window.innerWidth) - 8, 64) + "px";
|
||||
lastItem = item.element;
|
||||
}
|
||||
if (layout.element.scrollWidth <= layout.element.clientWidth) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (lastItem) {
|
||||
lastItem.style.maxWidth = Math.max(Math.min(lastItem.clientWidth, window.innerWidth) - 8, 64) + "px";
|
||||
}
|
||||
layout.children.forEach((item: Layout | Wnd) => {
|
||||
if (item instanceof Layout && item.size !== "0px") {
|
||||
adjustLayout(item);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import {Constants} from "../constants";
|
||||
import {webFrame} from "electron";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {getInstanceById, JSONToCenter} from "../layout/util";
|
||||
import {adjustLayout, getInstanceById, JSONToCenter} from "../layout/util";
|
||||
import {resizeTabs} from "../layout/tabUtil";
|
||||
import {initStatus} from "../layout/status";
|
||||
import {appearance} from "../config/appearance";
|
||||
|
|
@ -41,6 +41,7 @@ export const init = (app: App) => {
|
|||
}]
|
||||
});
|
||||
window.siyuan.layout.centerLayout = window.siyuan.layout.layout;
|
||||
adjustLayout(window.siyuan.layout.centerLayout);
|
||||
afterLayout(app);
|
||||
});
|
||||
initStatus(true);
|
||||
|
|
@ -53,6 +54,7 @@ export const init = (app: App) => {
|
|||
window.addEventListener("resize", () => {
|
||||
window.clearTimeout(resizeTimeout);
|
||||
resizeTimeout = window.setTimeout(() => {
|
||||
adjustLayout(window.siyuan.layout.centerLayout);
|
||||
resizeTabs();
|
||||
}, 200);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue