From ea72a28a7032c0fbe90d70aa547f949c449c359b Mon Sep 17 00:00:00 2001 From: Pavel Kvach Date: Tue, 5 Mar 2024 07:42:35 +0200 Subject: [PATCH] feat(notion-calendar): Add Notion Calendar integration (#2272) * feat(notion-calendar): Add Notion Calendar integration Closes #2271 * feat(notion-calendar): move calendar to notion.so file * feat(notion-calendar): remove notion calendar from integrations md file --------- Co-authored-by: Shrey Gupta --- src/content/notion.js | 24 ++++++++++++++++++++++++ src/styles/style.css | 5 +++++ 2 files changed, 29 insertions(+) diff --git a/src/content/notion.js b/src/content/notion.js index ad5d0ea0e..2a2da8f33 100644 --- a/src/content/notion.js +++ b/src/content/notion.js @@ -83,3 +83,27 @@ togglbutton.render( elem.prepend(wrapper); } ); + +/** + * @name Notion Calendar + * @urlAlias calendar.notion.so + * @urlRegex *://calendar.notion.so/* + */ +togglbutton.render( + 'div[data-context-panel-root]:not(.toggl)', + { observe: true }, + function (elem) { + function getDescription () { + const descriptionElem = elem.querySelector('div[contenteditable="true"]'); + return descriptionElem ? descriptionElem.textContent.trim() : ''; + } + if(!window.location.hostname.includes('calendar.notion.so')) return; + const link = togglbutton.createTimerLink({ + className: 'notion-calendar', + description: getDescription + }); + + elem.firstChild.prepend(link); + } +); + diff --git a/src/styles/style.css b/src/styles/style.css index a53e8d85d..694e0a742 100644 --- a/src/styles/style.css +++ b/src/styles/style.css @@ -1331,6 +1331,11 @@ body.notion-body.dark .toggl-button.notion { display: none !important; } +/********* NOTION CALENDAR *********/ +.toggl-button.notion-calendar { + padding: 12px; +} + /********* TURTLE *********/ .turtle-toggl-wrapper { display: inline-block;