mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
This commit is contained in:
parent
23f83b3665
commit
40fd9325c5
1 changed files with 99 additions and 100 deletions
|
|
@ -598,7 +598,9 @@ export const getInstanceById = (id: string, layout = window.siyuan.layout.center
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addResize = (obj: Layout | Wnd) => {
|
export const addResize = (obj: Layout | Wnd) => {
|
||||||
if (obj.resize) {
|
if (!obj.resize) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const resizeWnd = (resizeElement: HTMLElement, direction: string) => {
|
const resizeWnd = (resizeElement: HTMLElement, direction: string) => {
|
||||||
const setSize = (item: HTMLElement, direction: string) => {
|
const setSize = (item: HTMLElement, direction: string) => {
|
||||||
if (item.classList.contains("fn__flex-1")) {
|
if (item.classList.contains("fn__flex-1")) {
|
||||||
|
|
@ -627,8 +629,16 @@ export const addResize = (obj: Layout | Wnd) => {
|
||||||
const previousElement = resizeElement.previousElementSibling as HTMLElement;
|
const previousElement = resizeElement.previousElementSibling as HTMLElement;
|
||||||
nextElement.style.overflow = "auto"; // 拖动时 layout__resize 会出现 https://github.com/siyuan-note/siyuan/issues/6221
|
nextElement.style.overflow = "auto"; // 拖动时 layout__resize 会出现 https://github.com/siyuan-note/siyuan/issues/6221
|
||||||
previousElement.style.overflow = "auto";
|
previousElement.style.overflow = "auto";
|
||||||
setSize(nextElement, direction);
|
if (!nextElement.nextElementSibling) {
|
||||||
|
if (!previousElement.previousElementSibling) {
|
||||||
setSize(previousElement, direction);
|
setSize(previousElement, direction);
|
||||||
|
} else {
|
||||||
|
setSize(nextElement, direction);
|
||||||
|
}
|
||||||
|
} else if (nextElement.nextElementSibling?.nextElementSibling &&
|
||||||
|
nextElement.parentElement.lastElementChild.isSameNode(nextElement.nextElementSibling.nextElementSibling)) {
|
||||||
|
setSize(previousElement, direction);
|
||||||
|
}
|
||||||
const x = event[direction === "lr" ? "clientX" : "clientY"];
|
const x = event[direction === "lr" ? "clientX" : "clientY"];
|
||||||
const previousSize = direction === "lr" ? previousElement.clientWidth : previousElement.clientHeight;
|
const previousSize = direction === "lr" ? previousElement.clientWidth : previousElement.clientHeight;
|
||||||
const nextSize = direction === "lr" ? nextElement.clientWidth : nextElement.clientHeight;
|
const nextSize = direction === "lr" ? nextElement.clientWidth : nextElement.clientHeight;
|
||||||
|
|
@ -657,8 +667,12 @@ export const addResize = (obj: Layout | Wnd) => {
|
||||||
if (window.siyuan.layout.rightDock?.layout.element.contains(nextElement) && nextNowSize < 320) {
|
if (window.siyuan.layout.rightDock?.layout.element.contains(nextElement) && nextNowSize < 320) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!previousElement.classList.contains("fn__flex-1")) {
|
||||||
previousElement.style[direction === "lr" ? "width" : "height"] = previousNowSize + "px";
|
previousElement.style[direction === "lr" ? "width" : "height"] = previousNowSize + "px";
|
||||||
|
}
|
||||||
|
if (!nextElement.classList.contains("fn__flex-1")) {
|
||||||
nextElement.style[direction === "lr" ? "width" : "height"] = nextNowSize + "px";
|
nextElement.style[direction === "lr" ? "width" : "height"] = nextNowSize + "px";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
documentSelf.onmouseup = () => {
|
documentSelf.onmouseup = () => {
|
||||||
|
|
@ -667,20 +681,6 @@ export const addResize = (obj: Layout | Wnd) => {
|
||||||
documentSelf.ondragstart = null;
|
documentSelf.ondragstart = null;
|
||||||
documentSelf.onselectstart = null;
|
documentSelf.onselectstart = null;
|
||||||
documentSelf.onselect = null;
|
documentSelf.onselect = null;
|
||||||
|
|
||||||
if (!nextElement.nextElementSibling) {
|
|
||||||
if (!previousElement.previousElementSibling) {
|
|
||||||
nextElement.style[direction === "lr" ? "width" : "height"] = "";
|
|
||||||
nextElement.classList.add("fn__flex-1");
|
|
||||||
} else {
|
|
||||||
previousElement.style[direction === "lr" ? "width" : "height"] = "";
|
|
||||||
previousElement.classList.add("fn__flex-1");
|
|
||||||
}
|
|
||||||
} else if (nextElement.nextElementSibling?.nextElementSibling &&
|
|
||||||
nextElement.parentElement.lastElementChild.isSameNode(nextElement.nextElementSibling.nextElementSibling)) {
|
|
||||||
nextElement.style[direction === "lr" ? "width" : "height"] = "";
|
|
||||||
nextElement.classList.add("fn__flex-1");
|
|
||||||
}
|
|
||||||
resizeTabs();
|
resizeTabs();
|
||||||
if (!isWindow()) {
|
if (!isWindow()) {
|
||||||
window.siyuan.layout.leftDock.setSize();
|
window.siyuan.layout.leftDock.setSize();
|
||||||
|
|
@ -704,7 +704,6 @@ export const addResize = (obj: Layout | Wnd) => {
|
||||||
resizeElement.classList.add("layout__resize");
|
resizeElement.classList.add("layout__resize");
|
||||||
obj.element.insertAdjacentElement("beforebegin", resizeElement);
|
obj.element.insertAdjacentElement("beforebegin", resizeElement);
|
||||||
resizeWnd(resizeElement, obj.resize);
|
resizeWnd(resizeElement, obj.resize);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const newCenterEmptyTab = () => {
|
export const newCenterEmptyTab = () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue