diff --git a/plugin/custom/plugins/templater.js b/plugin/custom/plugins/templater.js index 65376314..7aa7ef19 100644 --- a/plugin/custom/plugins/templater.js +++ b/plugin/custom/plugins/templater.js @@ -21,7 +21,6 @@ class templater extends BaseCustomPlugin { { label: "模板", type: "select", - selected: "option2", list: options, } ] diff --git a/plugin/window_tab/index.js b/plugin/window_tab/index.js index 5f31e1b5..07b040ec 100644 --- a/plugin/window_tab/index.js +++ b/plugin/window_tab/index.js @@ -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 = () => { @@ -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 { @@ -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"; // 新窗口打开