Skip to content

Commit

Permalink
Merge pull request #114 from obgnail/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
obgnail authored Aug 23, 2023
2 parents ca7cf24 + 897b7d0 commit 06697ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
1 change: 0 additions & 1 deletion plugin/custom/plugins/templater.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class templater extends BaseCustomPlugin {
{
label: "模板",
type: "select",
selected: "option2",
list: options,
}
]
Expand Down
42 changes: 25 additions & 17 deletions plugin/window_tab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,6 @@ class windowTabBarPlugin extends global._basePlugin {
windowTab.id = "plugin-window-tab";
windowTab.innerHTML = div;
this.utils.insertDiv(windowTab);

if (!this.config.HIDE_WINDOW_TITLE_BAR) {
const {height, top} = document.querySelector("header").getBoundingClientRect();
windowTab.style.top = height + top + 5 + "px";
}

if (this.config.CHANGE_CONTENT_TOP) {
const {height, top} = windowTab.getBoundingClientRect();
document.querySelector("content").style.top = top + height + "px";
}

if (this.config.CHANGE_NOTIFICATION_Z_INDEX) {
const container = document.querySelector(".md-notification-container");
if (container) {
container.style.zIndex = "99999";
}
}
}

hotkey = () => {
Expand Down Expand Up @@ -226,6 +209,8 @@ class windowTabBarPlugin extends global._basePlugin {
filePath && this.openTab(filePath);
});

this.utils.loopDetector(() => !!document.querySelector("header").getBoundingClientRect().height, this.adjustTop);

if (this.config.DRAG_STYLE === 1) {
this.sort1();
} else {
Expand Down Expand Up @@ -295,6 +280,29 @@ class windowTabBarPlugin extends global._basePlugin {
}, true)
}

adjustTop = () => {
setTimeout(() => {
const windowTab = document.querySelector("#plugin-window-tab");
if (!this.config.HIDE_WINDOW_TITLE_BAR) {
const {height, top} = document.querySelector("header").getBoundingClientRect();
windowTab.style.top = height + top + "px";
}

if (this.config.CHANGE_CONTENT_TOP) {
const {height, top} = windowTab.getBoundingClientRect();
document.querySelector("content").style.top = top + height + "px";
document.querySelector("#typora-source").style.top = top + height + "px";
}

if (this.config.CHANGE_NOTIFICATION_Z_INDEX) {
const container = document.querySelector(".md-notification-container");
if (container) {
container.style.zIndex = "99999";
}
}
}, 200)
}

showTabsIfNeed = show => document.querySelector("#plugin-window-tab").style.display = (show) ? "" : "none";

// 新窗口打开
Expand Down

0 comments on commit 06697ac

Please sign in to comment.