diff --git a/src/modules/sidebars/sidebars.ts b/src/modules/sidebars/sidebars.ts index 1333d11..3f2e91d 100644 --- a/src/modules/sidebars/sidebars.ts +++ b/src/modules/sidebars/sidebars.ts @@ -1,53 +1,8 @@ -import { doc, body } from '../globals/globals'; - import './sidebars.css'; // Reposition right sidebar toggle button export const rightSidebarLoad = () => { - const toggleRightSidebar = doc.querySelector('#right-sidebar .toggle-right-sidebar'); - reorderRightSidebarToggleButton(toggleRightSidebar ? true : false); - // Listen sidebar update - logseq.App.onSidebarVisibleChanged(({visible}) => { - onSidebarVisibleChangedCallback(visible); - }); } export const rightSidebarUnload = () => { - const hideRightSidebarButton = doc.querySelector('#head .hide-right-sidebar-button'); - const rightToolbarPlaceholder = doc.querySelector('.cp__right-sidebar-topbar'); - if (rightToolbarPlaceholder && hideRightSidebarButton) { - rightToolbarPlaceholder.insertAdjacentElement('beforeend', hideRightSidebarButton); - }} - -export const reorderRightSidebarToggleButton = (visible: boolean) => { - if (visible) { - const hideRightSidebarButton = doc.querySelector('#right-sidebar .toggle-right-sidebar'); - hideRightSidebarButton?.classList.add('hide-right-sidebar-button') - const headToolbar = doc.querySelector('#head .r'); - if (headToolbar && hideRightSidebarButton) { - headToolbar.insertAdjacentElement('beforeend', hideRightSidebarButton); - } - } else { - doc.querySelector('#head .hide-right-sidebar-button')?.remove(); - } -} - -export const origRightSidebarToggleButton = (visible: boolean) => { - if (visible) { - const hideRightSidebarButton = doc.querySelector('#right-sidebar .toggle-right-sidebar'); - const headToolbar = doc.querySelector('.cp__right-sidebar-topbar'); - if (headToolbar && hideRightSidebarButton) { - headToolbar.insertAdjacentElement('beforeend', hideRightSidebarButton); - } - }// else { - // doc.querySelector('#head .hide-right-sidebar-button')?.remove(); - // } -} - -// Sidebar toggled -const onSidebarVisibleChangedCallback = (visible: boolean) => { - if (!body.classList.contains('is-awUi-enabled')) { - return; - } - reorderRightSidebarToggleButton(visible); } diff --git a/src/plugin/plugin.ts b/src/plugin/plugin.ts index 12c076c..450f060 100644 --- a/src/plugin/plugin.ts +++ b/src/plugin/plugin.ts @@ -78,10 +78,8 @@ const runStuff = () => { tabsPositionToggle(); tabsStyleToggle(); vaultButtonToggle(); - }, 2000); - setTimeout(() => { rightSidebarLoad(); - }, 3000) + }, 2000); } const stopStuff = () => {