mirror of
				https://github.com/notion-enhancer/notion-enhancer.git
				synced 2025-11-01 06:38:08 +11:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			47cfece013
			...
			6e80cf77b5
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 6e80cf77b5 | |||
| bbc8c7a1e0 | 
| @ -6,15 +6,15 @@ | ||||
| 
 | ||||
| let __$wrapper; | ||||
| const setupWrapper = () => { | ||||
|     const notionHelp = ".notion-help-button", | ||||
|     const notionAi = ".notion-ai-button", | ||||
|       { html, addMutationListener } = globalThis.__enhancerApi, | ||||
|       { removeMutationListener } = globalThis.__enhancerApi; | ||||
|     return (__$wrapper ??= new Promise((res) => { | ||||
|       const addToDom = () => { | ||||
|         const $help = document.querySelector(notionHelp); | ||||
|         if (!$help) return; | ||||
|         const $notionAi = document.querySelector(notionAi); | ||||
|         if (!$notionAi) return; | ||||
|         const gap = 12, | ||||
|           computedStyles = getComputedStyle($help), | ||||
|           computedStyles = getComputedStyle($notionAi), | ||||
|           visible = computedStyles.getPropertyValue("display") !== "none", | ||||
|           width = computedStyles.getPropertyValue("width"), | ||||
|           right = computedStyles.getPropertyValue("right"), | ||||
| @ -25,10 +25,10 @@ const setupWrapper = () => { | ||||
|             style="right:${offset}px" | ||||
|           ></div>`; | ||||
|         removeMutationListener(addToDom); | ||||
|         $help.after($wrapper); | ||||
|         $notionAi.after($wrapper); | ||||
|         res($wrapper); | ||||
|       }; | ||||
|       addMutationListener(notionHelp, addToDom); | ||||
|       addMutationListener(notionAi, addToDom); | ||||
|       addToDom(); | ||||
|     })); | ||||
|   }, | ||||
|  | ||||
| @ -206,9 +206,8 @@ function Panel({ | ||||
|     }; | ||||
| 
 | ||||
|   const animationState = { ...closedWidth }, | ||||
|     easing = "cubic-bezier(0.4, 0, 0.2, 1)", | ||||
|     animate = ($target, keyframes) => { | ||||
|       const opts = { fill: "forwards", duration: transitionDuration, easing }; | ||||
|       const opts = { fill: "forwards", duration: transitionDuration, easing: "ease" }; | ||||
|       $target.animate(keyframes, opts); | ||||
|     }, | ||||
|     animatePanel = (to) => { | ||||
| @ -303,10 +302,10 @@ function Panel({ | ||||
|   // moves help button out of the way of open panel.
 | ||||
|   // normally would place outside of an island, but in
 | ||||
|   // this case is necessary for syncing up animations
 | ||||
|   const notionHelp = ".notion-help-button", | ||||
|   const notionAi = ".notion-ai-button", | ||||
|     floatingButtons = ".notion-enhancer--floating-buttons", | ||||
|     repositionCorner = async (offset) => { | ||||
|       const $help = document.querySelector(notionHelp), | ||||
|       const $help = document.querySelector(notionAi), | ||||
|         $floating = document.querySelector(floatingButtons); | ||||
|       offset ??= await getWidth(); | ||||
|       if (isNaN(offset)) offset = minWidth; | ||||
| @ -329,7 +328,7 @@ function Panel({ | ||||
|       } | ||||
|       if ($help || $floating) removeMutationListener(repositionCorner); | ||||
|     }; | ||||
|   const corner = `${notionHelp}, ${floatingButtons}`; | ||||
|   const corner = `${notionAi}, ${floatingButtons}`; | ||||
|   addMutationListener(corner, repositionCorner, { subtree: false }); | ||||
| 
 | ||||
|   $panel.pin = () => { | ||||
|  | ||||
| @ -5,8 +5,9 @@ | ||||
|  * (https://notion-enhancer.github.io/) under the MIT license | ||||
|  */ | ||||
| 
 | ||||
| /* hide topbar */ | ||||
| .notion-sidebar-container[aria-hidden] ~ div .notion-topbar { | ||||
| /* hide topbar and ai */ | ||||
| .notion-sidebar-container[aria-hidden] ~ div .notion-topbar, | ||||
| .notion-sidebar-container[aria-hidden] ~ div .notion-ai-button { | ||||
|   opacity: 0 !important; | ||||
|   transition: opacity 200ms ease-in-out !important; | ||||
| } | ||||
|  | ||||
| @ -19,7 +19,7 @@ export default async (api, db) => { | ||||
|     scrollBehavior = (await db.get("smoothScrolling")) ? "smooth" : "auto", | ||||
|     scroller = ".notion-frame .notion-scroller"; | ||||
| 
 | ||||
|   let $scroller, $todayButton; | ||||
|   let $scroller, $today; | ||||
|   const scrollTo = (top, behavior) => $scroller?.scroll({ top, behavior }), | ||||
|     $scrollToBottom = html`<${FloatingButton} | ||||
|       onclick="${() => scrollTo($scroller.scrollHeight, scrollBehavior)}" | ||||
| @ -50,27 +50,32 @@ export default async (api, db) => { | ||||
|       } else removeFloatingButton($scrollToTop); | ||||
|     }, | ||||
|     onTodayLoaded = () => { | ||||
|       const $bubble = document.querySelector(todayBubble); | ||||
|       if (!$bubble) return; | ||||
|       // calendar will jump anyway when pinning the current month,
 | ||||
|       // so ignore smooth scroll setting and jump direct to week
 | ||||
|       const $bubble = document.querySelector(todayBubble); | ||||
|       if (!$bubble) return; | ||||
|       scrollTo($bubble.offsetParent.offsetParent.offsetTop + 57, "auto"); | ||||
|       removeMutationListener(onTodayLoaded); | ||||
|     }, | ||||
|     onTodayClicked = () => { | ||||
|       removeMutationListener(onTodayLoaded); | ||||
|       addMutationListener(todayBubble, onTodayLoaded); | ||||
|       // if calendar does not refresh: jump direct to current week
 | ||||
|       // if calendar does refresh: wait, then jump to current week
 | ||||
|       requestIdleCallback(() => { | ||||
|         onTodayLoaded(); | ||||
|         addMutationListener(todayBubble, onTodayLoaded); | ||||
|       }); | ||||
|     }, | ||||
|     setup = () => { | ||||
|       if (document.contains($scroller)) return; | ||||
|       $scroller = document.querySelector(scroller); | ||||
|       $scroller?.removeEventListener("scroll", onPageScrolled); | ||||
|       $scroller?.addEventListener("scroll", onPageScrolled); | ||||
|       onPageScrolled(); | ||||
|       if (jumpToWeek) { | ||||
|         $todayButton = document.querySelector(todayButton); | ||||
|         $todayButton?.removeEventListener("click", onTodayClicked); | ||||
|         $todayButton?.addEventListener("click", onTodayClicked); | ||||
|       if (!document.contains($scroller)) { | ||||
|         $scroller = document.querySelector(scroller); | ||||
|         $scroller?.removeEventListener("scroll", onPageScrolled); | ||||
|         $scroller?.addEventListener("scroll", onPageScrolled); | ||||
|         onPageScrolled(); | ||||
|       } | ||||
|       if (jumpToWeek && !document.contains($today)) { | ||||
|         $today = document.querySelector(todayButton); | ||||
|         $today?.removeEventListener("click", onTodayClicked); | ||||
|         $today?.addEventListener("click", onTodayClicked); | ||||
|       } | ||||
|     }; | ||||
|   addMutationListener(scroller, setup, { subtree: false }); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user