mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-19 11:09:03 +00:00
global linking blocks: option: show the page link button
This commit is contained in:
parent
154cff8b1a
commit
657bec2fa4
@ -19,6 +19,14 @@ module.exports = {
|
||||
link: 'https://github.com/admiraldus',
|
||||
avatar: 'https://raw.githubusercontent.com/admiraldus/admiraldus/main/module.gif',
|
||||
},
|
||||
options: [
|
||||
{
|
||||
key: 'hidePageButton',
|
||||
label: 'show the page link button',
|
||||
type: 'toggle',
|
||||
value: true,
|
||||
},
|
||||
],
|
||||
hacks: {
|
||||
'renderer/preload.js'(store, __exports) {
|
||||
document.addEventListener('readystatechange', () => {
|
||||
@ -43,13 +51,17 @@ module.exports = {
|
||||
const pageClass = 'admiraldus-glb-page-button';
|
||||
const blockClass = 'admiraldus-glb-block-button';
|
||||
const spanClass = 'admiraldus-glb-span-hide';
|
||||
|
||||
if (store().hidePageButton) {
|
||||
/**
|
||||
* Create the page link button and append it to the topbar.
|
||||
*
|
||||
* @return {create} Returns "create()" if not appended.
|
||||
*/
|
||||
const pageButton = !function create() {
|
||||
const pageButton = function create() {
|
||||
const target = x$.sel('.notion-topbar-share-menu');
|
||||
if (target === null) return;
|
||||
|
||||
const attr = [
|
||||
`class="${pageClass}" role="button" tabindex="0"`,
|
||||
`class="${spanClass}"`,
|
||||
@ -63,7 +75,19 @@ module.exports = {
|
||||
|
||||
target.before(html);
|
||||
if (html === null) return create();
|
||||
}();
|
||||
};
|
||||
pageButton();
|
||||
|
||||
/**
|
||||
* Observer for the topbar.
|
||||
*/
|
||||
x$.obs(() => {
|
||||
if (x$.sel(`.${pageClass}`) !== null) return;
|
||||
pageButton();
|
||||
}, x$.sel('.notion-topbar'), {
|
||||
subtree: true, childList: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the block link button and append it to the block menu.
|
||||
|
Loading…
Reference in New Issue
Block a user