mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-06 21:49:03 +00:00
outliner: more reliable page detection
This commit is contained in:
parent
7bdae2faa6
commit
da85adcd33
@ -39,6 +39,8 @@ export default async function ({ web, components }, db) {
|
|||||||
|
|
||||||
function updateHeadings() {
|
function updateHeadings() {
|
||||||
if (!$page) return;
|
if (!$page) return;
|
||||||
|
$notice.innerText = pageNoticeText;
|
||||||
|
$headingList.style.display = '';
|
||||||
const $headerBlocks = $page.querySelectorAll('[class^="notion-"][class*="header-block"]'),
|
const $headerBlocks = $page.querySelectorAll('[class^="notion-"][class*="header-block"]'),
|
||||||
$fragment = web.html`<div></div>`;
|
$fragment = web.html`<div></div>`;
|
||||||
let depth = 0,
|
let depth = 0,
|
||||||
@ -73,21 +75,15 @@ export default async function ({ web, components }, db) {
|
|||||||
if (document.contains($page)) {
|
if (document.contains($page)) {
|
||||||
updateHeadings();
|
updateHeadings();
|
||||||
} else {
|
} else {
|
||||||
$page = document.getElementsByClassName('notion-page-content')[0];
|
$page = document.querySelector('.notion-page-content');
|
||||||
if ($page) {
|
if (!$page) {
|
||||||
$notice.innerText = pageNoticeText;
|
|
||||||
$headingList.style.display = '';
|
|
||||||
updateHeadings();
|
|
||||||
} else {
|
|
||||||
$notice.innerText = dbNoticeText;
|
$notice.innerText = dbNoticeText;
|
||||||
$headingList.style.display = 'none';
|
$headingList.style.display = 'none';
|
||||||
}
|
} else updateHeadings();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
web.addDocumentObserver(pageObserver, [
|
web.addDocumentObserver(pageObserver, [
|
||||||
'.notion-header-block',
|
'.notion-page-content',
|
||||||
'.notion-sub_header-block',
|
|
||||||
'.notion-sub_sub_header-block',
|
|
||||||
'.notion-collection_view_page-block',
|
'.notion-collection_view_page-block',
|
||||||
]);
|
]);
|
||||||
pageObserver();
|
pageObserver();
|
||||||
|
Loading…
Reference in New Issue
Block a user