mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-03 12:19:02 +00:00
fix(outliner): correctly indent h1 > h3 > h2 heading sequences
This commit is contained in:
parent
7ad446ade8
commit
8e9dcfac95
@ -84,10 +84,17 @@ export default async (api, db) => {
|
||||
updateHeadings = debounce(() => {
|
||||
$toc.innerHTML = "";
|
||||
if (!$page) return;
|
||||
let indent = 0,
|
||||
prev_level = 0;
|
||||
const $frag = document.createDocumentFragment();
|
||||
for (const $heading of getHeadings()) {
|
||||
const level = getHeadingLevel($heading);
|
||||
if (level === 1) indent = 1;
|
||||
else if (level > prev_level) indent = Math.min(indent + 1, level);
|
||||
else if (level < prev_level) indent = Math.max(indent - 1, level);
|
||||
prev_level = level;
|
||||
$heading._$outline = html`<${Heading}
|
||||
indent=${getHeadingLevel($heading)}
|
||||
...${{ indent }}
|
||||
onclick=${() => {
|
||||
if (!$scroller) return;
|
||||
const top = getBlockOffset($heading) - 24;
|
||||
|
Loading…
Reference in New Issue
Block a user