diff --git a/app/src/layout/Tab.ts b/app/src/layout/Tab.ts index 237fb0a91..b6208b70c 100644 --- a/app/src/layout/Tab.ts +++ b/app/src/layout/Tab.ts @@ -8,7 +8,7 @@ import {escapeGreat, escapeHtml} from "../util/escape"; import {unicode2Emoji} from "../emoji"; import {fetchPost} from "../util/fetch"; import {hideTooltip, showTooltip} from "../dialog/tooltip"; -import {isTouchDevice} from "../util/functions"; +import {isTouchDevice, isWindow} from "../util/functions"; /// #if !BROWSER import {openNewWindow} from "../window/openNewWindow"; import {ipcRenderer} from "electron"; @@ -99,6 +99,9 @@ export class Tab { tabElement.style.opacity = "0.38"; window.siyuan.dragElement = this.headElement; } + if (isWindow() && this.headElement.getBoundingClientRect().top <= 0) { + ((this.headElement.parentElement.parentElement.querySelector(".item--readonly .fn__flex-1") as HTMLElement).style as CSSStyleDeclarationElectron).WebkitAppRegion = ""; + } }); this.headElement.addEventListener("dragend", (event: DragEvent & { target: HTMLElement }) => { const tabElement = hasClosestByTag(event.target, "LI"); @@ -136,6 +139,9 @@ export class Tab { } }); } + if (isWindow() && this.headElement.getBoundingClientRect().top <= 0) { + ((this.headElement.parentElement.parentElement.querySelector(".item--readonly .fn__flex-1") as HTMLElement).style as CSSStyleDeclarationElectron).WebkitAppRegion = "drag"; + } }); } diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index 1e0934553..003c67c52 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -231,7 +231,6 @@ export class Wnd { } } }); - this.headersElement.parentElement.addEventListener("drop", function (event: DragEvent & { target: HTMLElement }) { diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 92eead7ca..d46efd65b 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -124,6 +124,10 @@ declare namespace CSS { const highlights: Map; } +interface CSSStyleDeclarationElectron extends CSSStyleDeclaration { + WebkitAppRegion: string +} + interface Window { echarts: { init(element: HTMLElement, theme?: string, options?: { diff --git a/app/src/window/setHeader.ts b/app/src/window/setHeader.ts index 19cc5a6af..cfeae50cc 100644 --- a/app/src/window/setHeader.ts +++ b/app/src/window/setHeader.ts @@ -18,11 +18,9 @@ export const setTabPosition = () => { const dragElement = headerElement.querySelector(".item--readonly .fn__flex-1") as HTMLElement; if (rect.top <= 0) { dragElement.style.height = dragElement.parentElement.clientHeight + "px"; - // @ts-ignore - dragElement.style.WebkitAppRegion = "drag"; + (dragElement.style as CSSStyleDeclarationElectron).WebkitAppRegion = "drag"; } else { - // @ts-ignore - dragElement.style.WebkitAppRegion = ""; + (dragElement.style as CSSStyleDeclarationElectron).WebkitAppRegion = ""; } const headersLastElement = headerElement.lastElementChild as HTMLElement; if ("darwin" === window.siyuan.config.system.os) {