This commit is contained in:
Vanessa 2023-02-12 11:34:01 +08:00
parent 88ece2c1ec
commit 15de73d74a
2 changed files with 45 additions and 25 deletions

View file

@ -102,18 +102,16 @@ right:0;
${this.position === "Top" ? ("top:" + (.5 + this.element.clientHeight + document.getElementById("toolbar").clientHeight) + "px") : ("bottom:" + (1 + this.element.clientHeight + document.getElementById("status").clientHeight) + "px")};`); ${this.position === "Top" ? ("top:" + (.5 + this.element.clientHeight + document.getElementById("toolbar").clientHeight) + "px") : ("bottom:" + (1 + this.element.clientHeight + document.getElementById("status").clientHeight) + "px")};`);
} }
target.setAttribute("aria-label", window.siyuan.languages.pin); target.setAttribute("aria-label", window.siyuan.languages.pin);
this.resizeElement.classList.add("fn__none");
} else { } else {
target.setAttribute("aria-label", window.siyuan.languages.unpin); target.setAttribute("aria-label", window.siyuan.languages.unpin);
} this.layout.element.style.opacity = ""
target.classList.toggle("dock__item--pin");
this.layout.element.classList.toggle("layout--float");
if (this.pin) {
if (hasActive) { if (hasActive) {
this.resizeElement.classList.remove("fn__none"); this.resizeElement.classList.remove("fn__none");
} }
} else {
this.resizeElement.classList.add("fn__none");
} }
target.classList.toggle("dock__item--pin");
this.layout.element.classList.toggle("layout--float");
event.preventDefault(); event.preventDefault();
break; break;
} }
@ -162,8 +160,34 @@ ${this.position === "Top" ? "top" : "bottom"}:-${this.layout.element.clientHeigh
} }
} }
public showDock() {
if (this.pin || !this.element.querySelector(".dock__item--active") || this.layout.element.style.opacity === "1") {
return;
}
if ((this.position === "Left" || this.position === "Right") &&
this.layout.element.clientWidth === 0 && this.layout.element.style.width.startsWith("0")) {
return;
}
console.log(2, this.layout.element.clientHeight, this.layout.element.style.height)
if ((this.position === "Top" || this.position === "Bottom") &&
this.layout.element.clientHeight === 0 && this.layout.element.style.height.startsWith("0")) {
return;
}
console.log(3)
this.layout.element.style.opacity = "1";
if (this.position === "Left") {
window.siyuan.layout.leftDock.layout.element.style.left = (window.siyuan.layout.leftDock.element.clientWidth + .5) + "px";
} else if (this.position === "Right") {
this.layout.element.style.right = (window.siyuan.layout.rightDock.element.clientWidth + .5) + "px";
} else if (this.position === "Top") {
this.layout.element.style.top = (document.getElementById("dockTop").clientHeight + document.getElementById("toolbar").clientHeight + .5) + "px";
} else if (this.position === "Bottom") {
this.layout.element.style.bottom = (document.getElementById("dockBottom").clientHeight + document.getElementById("status").clientHeight + 1) + "px";
}
}
public hideDock() { public hideDock() {
if (this.layout.element.style.opacity === "0") { if (this.layout.element.style.opacity === "0" || this.pin) {
return; return;
} }
this.layout.element.style.opacity = "0"; this.layout.element.style.opacity = "0";
@ -201,6 +225,7 @@ ${this.position === "Top" ? "top" : "bottom"}:-${this.layout.element.clientHeigh
} }
}); });
if (needFocus) { if (needFocus) {
this.showDock()
return; return;
} }
} }
@ -217,6 +242,7 @@ ${this.position === "Top" ? "top" : "bottom"}:-${this.layout.element.clientHeigh
document.getElementById("drag").classList.remove("fn__hidden"); document.getElementById("drag").classList.remove("fn__hidden");
} }
this.resizeElement.classList.add("fn__none"); this.resizeElement.classList.add("fn__none");
this.hideDock();
} }
} else { } else {
this.element.querySelectorAll(`.dock__item--active[data-index="${index}"]`).forEach(item => { this.element.querySelectorAll(`.dock__item--active[data-index="${index}"]`).forEach(item => {
@ -330,11 +356,13 @@ ${this.position === "Top" ? "top" : "bottom"}:-${this.layout.element.clientHeigh
} else { } else {
this.layout.element.style.height = this.getMaxSize() + "px"; this.layout.element.style.height = this.getMaxSize() + "px";
} }
console.log(this.layout.element.style.height, this.layout.element.clientHeight)
if ((type === "graph" || type === "globalGraph") && if ((type === "graph" || type === "globalGraph") &&
document.querySelector("body").classList.contains("body--win32") && this.layout.element.querySelector(".fullscreen")) { document.querySelector("body").classList.contains("body--win32") && this.layout.element.querySelector(".fullscreen")) {
document.getElementById("drag").classList.add("fn__hidden"); document.getElementById("drag").classList.add("fn__hidden");
} }
if (this.pin) { if (this.pin) {
this.layout.element.style.opacity = ""
this.resizeElement.classList.remove("fn__none"); this.resizeElement.classList.remove("fn__none");
} }
} }
@ -393,6 +421,7 @@ ${this.position === "Top" ? "top" : "bottom"}:-${this.layout.element.clientHeigh
anotherWnd.element.style.width = ""; anotherWnd.element.style.width = "";
} }
resizeTabs(); resizeTabs();
this.showDock();
} }
public add(index: number, sourceElement: Element) { public add(index: number, sourceElement: Element) {
@ -478,7 +507,7 @@ ${this.position === "Top" ? "top" : "bottom"}:-${this.layout.element.clientHeigh
this.element.querySelectorAll(".dock__item--active").forEach((item) => { this.element.querySelectorAll(".dock__item--active").forEach((item) => {
let size; let size;
if (this.position === "Left" || this.position === "Right") { if (this.position === "Left" || this.position === "Right") {
size = parseInt(item.getAttribute("data-width")) || 240; // 240 兼容历史数据 size = parseInt(item.getAttribute("data-width")) || 240;
} else { } else {
size = parseInt(item.getAttribute("data-height")) || 240; size = parseInt(item.getAttribute("data-height")) || 240;
} }

View file

@ -101,10 +101,8 @@ export const globalShortcut = () => {
if (event.clientY > document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight && if (event.clientY > document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight &&
event.clientY < window.innerHeight - document.getElementById("status").clientHeight - document.getElementById("dockBottom").clientHeight) { event.clientY < window.innerHeight - document.getElementById("status").clientHeight - document.getElementById("dockBottom").clientHeight) {
if (!hasClosestByClassName(event.target as HTMLElement, "b3-menu") && if (!hasClosestByClassName(event.target as HTMLElement, "b3-menu") &&
!hasClosestByClassName(event.target as HTMLElement, "layout--float") && !hasClosestByClassName(event.target as HTMLElement, "layout--float")) {
window.siyuan.layout.leftDock.layout.element.style.opacity !== "1") { window.siyuan.layout.leftDock.showDock();
window.siyuan.layout.leftDock.layout.element.style.left = (window.siyuan.layout.leftDock.element.clientWidth + .5) + "px";
window.siyuan.layout.leftDock.layout.element.style.opacity = "1";
} }
} else { } else {
window.siyuan.layout.leftDock.hideDock(); window.siyuan.layout.leftDock.hideDock();
@ -114,9 +112,8 @@ export const globalShortcut = () => {
if (!window.siyuan.layout.rightDock.pin && window.siyuan.layout.rightDock.layout.element.clientWidth > 0) { if (!window.siyuan.layout.rightDock.pin && window.siyuan.layout.rightDock.layout.element.clientWidth > 0) {
if (event.clientY > document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight && if (event.clientY > document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight &&
event.clientY < window.innerHeight - document.getElementById("status").clientHeight - document.getElementById("dockBottom").clientHeight) { event.clientY < window.innerHeight - document.getElementById("status").clientHeight - document.getElementById("dockBottom").clientHeight) {
if (!hasClosestByClassName(event.target as HTMLElement, "layout--float") && window.siyuan.layout.rightDock.layout.element.style.opacity !== "1") { if (!hasClosestByClassName(event.target as HTMLElement, "layout--float")) {
window.siyuan.layout.rightDock.layout.element.style.right = (window.siyuan.layout.rightDock.element.clientWidth + .5) + "px"; window.siyuan.layout.rightDock.showDock();
window.siyuan.layout.rightDock.layout.element.style.opacity = "1";
} }
} else { } else {
window.siyuan.layout.rightDock.hideDock(); window.siyuan.layout.rightDock.hideDock();
@ -125,15 +122,9 @@ export const globalShortcut = () => {
} }
if (event.clientY < 75) { if (event.clientY < 75) {
if (!window.siyuan.layout.topDock.pin && window.siyuan.layout.topDock.layout.element.clientHeight > 0 && window.siyuan.layout.topDock.layout.element.style.opacity !== "1") { window.siyuan.layout.topDock.showDock();
window.siyuan.layout.topDock.layout.element.style.top = (document.getElementById("dockTop").clientHeight + document.getElementById("toolbar").clientHeight + .5) + "px";
window.siyuan.layout.topDock.layout.element.style.opacity = "1";
}
} else if (event.clientY > window.innerHeight - 73) { } else if (event.clientY > window.innerHeight - 73) {
if (!window.siyuan.layout.bottomDock.pin && window.siyuan.layout.bottomDock.layout.element.clientHeight > 0 && window.siyuan.layout.bottomDock.layout.element.style.opacity !== "1") { window.siyuan.layout.bottomDock.showDock()
window.siyuan.layout.bottomDock.layout.element.style.bottom = (document.getElementById("dockBottom").clientHeight + document.getElementById("status").clientHeight + 1) + "px";
window.siyuan.layout.bottomDock.layout.element.style.opacity = "1";
}
} }
const eventPath0 = event.composedPath()[0] as HTMLElement; const eventPath0 = event.composedPath()[0] as HTMLElement;