From 67b396e5110c80d653afd3d316460db45c9dd9b8 Mon Sep 17 00:00:00 2001 From: CloudHill Date: Mon, 7 Dec 2020 16:26:40 +0700 Subject: [PATCH] outliner now follows the headers' inline styling --- mods/outliner/mod.js | 2 +- mods/outliner/panel.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mods/outliner/mod.js b/mods/outliner/mod.js index 56efa89..0dd85cf 100644 --- a/mods/outliner/mod.js +++ b/mods/outliner/mod.js @@ -14,7 +14,7 @@ module.exports = { tags: ['extension', 'panel'], name: 'outliner', desc: 'table of contents.', - version: '1.0.0', + version: '1.1.0', author: 'CloudHill', options: [ { diff --git a/mods/outliner/panel.js b/mods/outliner/panel.js index 044c8d7..428c8b6 100644 --- a/mods/outliner/panel.js +++ b/mods/outliner/panel.js @@ -69,16 +69,18 @@ module.exports = (store, __exports) => { const pageContent = document.querySelector('.notion-page-content'); const headerBlocks = pageContent.querySelectorAll('[class*="header-block"]'); - headerBlocks.forEach(block => { - const blockId = block.dataset.blockId.replace(/-/g, ''); - const placeholder = block.querySelector('[placeholder]').getAttribute('placeholder'); - const header = createElement(` + headerBlocks.forEach(header => { + const blockId = header.dataset.blockId.replace(/-/g, ''); + const headerEl = header.querySelector('[placeholder]'); + const placeholder = headerEl.getAttribute('placeholder'); + + const outlineHeader = createElement(`
${block.innerText} + outline-placeholder="${placeholder}">${headerEl.innerHTML}
`); - outline.append(header); + outline.append(outlineHeader); }) }