mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-11 15:59:03 +00:00
commit
4e1a28df3d
@ -43,18 +43,12 @@ export default async function ({ web, components }, db) {
|
|||||||
$headingList.style.display = '';
|
$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 indent = 0;
|
||||||
indent = 0;
|
|
||||||
for (const $header of $headerBlocks) {
|
for (const $header of $headerBlocks) {
|
||||||
const id = $header.dataset.blockId.replace(/-/g, ''),
|
const id = $header.dataset.blockId.replace(/-/g, ''),
|
||||||
placeholder = $header.querySelector('[placeholder]').getAttribute('placeholder'),
|
placeholder = $header.querySelector('[placeholder]').getAttribute('placeholder'),
|
||||||
headerDepth = +[...placeholder].reverse()[0];
|
headerDepth = +[...placeholder].reverse()[0];
|
||||||
if (depth && depth < headerDepth) {
|
indent = (headerDepth-1) * 18;
|
||||||
indent += 18;
|
|
||||||
} else if (depth > headerDepth) {
|
|
||||||
indent = Math.max(indent - 18, 0);
|
|
||||||
}
|
|
||||||
depth = headerDepth;
|
|
||||||
const $outlineHeader = web.render(
|
const $outlineHeader = web.render(
|
||||||
web.html`<a href="#${id}" class="outliner--header"
|
web.html`<a href="#${id}" class="outliner--header"
|
||||||
placeholder="${web.escape(placeholder)}"
|
placeholder="${web.escape(placeholder)}"
|
||||||
|
Loading…
Reference in New Issue
Block a user