-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(notion): Timer link on Notion main page
Creates timer link on left side of page title, which works on the main page and popups
- Loading branch information
1 parent
6526069
commit 913ca0d
Showing
2 changed files
with
11 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
'use strict'; | ||
|
||
// Selectors here are madness, it works for as of Dec 4th 2019 | ||
// Button renders in popup/dialog view | ||
// Button renders left of page title | ||
togglbutton.render( | ||
'.notion-peek-renderer:not(.toggl)', | ||
'.notion-page-controls + div:not(.toggl)', | ||
{ observe: true }, | ||
function (elem) { | ||
elem.style.position = 'relative'; | ||
|
||
function getDescription () { | ||
const descriptionElem = elem.querySelector('.notion-scroller .notion-selectable div[contenteditable="true"]'); | ||
const descriptionElem = elem; | ||
return descriptionElem ? descriptionElem.textContent.trim() : ''; | ||
} | ||
|
||
const link = togglbutton.createTimerLink({ | ||
className: 'notion', | ||
buttonType: 'minimal', | ||
description: getDescription | ||
}); | ||
|
||
const root = elem.querySelector('div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3)'); | ||
if (root) { | ||
root.prepend(link); | ||
} | ||
elem.prepend(link); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters