mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-04 04:39:03 +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(() => {
|
updateHeadings = debounce(() => {
|
||||||
$toc.innerHTML = "";
|
$toc.innerHTML = "";
|
||||||
if (!$page) return;
|
if (!$page) return;
|
||||||
|
let indent = 0,
|
||||||
|
prev_level = 0;
|
||||||
const $frag = document.createDocumentFragment();
|
const $frag = document.createDocumentFragment();
|
||||||
for (const $heading of getHeadings()) {
|
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}
|
$heading._$outline = html`<${Heading}
|
||||||
indent=${getHeadingLevel($heading)}
|
...${{ indent }}
|
||||||
onclick=${() => {
|
onclick=${() => {
|
||||||
if (!$scroller) return;
|
if (!$scroller) return;
|
||||||
const top = getBlockOffset($heading) - 24;
|
const top = getBlockOffset($heading) - 24;
|
||||||
|
Loading…
Reference in New Issue
Block a user