Skip to content
This repository has been archived by the owner on Mar 6, 2022. It is now read-only.

Make minor fixes to remove warning #30

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const ROOT_LEVEL_CLASS_NAMES = ["notion-page-content", "notion-table-view", "not
function alignListItemsToRight() {
const items = getListItems()

if (!items.length) return null;

items.forEach((item) => {
item.style["text-align"] = "start"
})
Expand All @@ -29,6 +31,8 @@ function getListItems() {
function setBlocksDirectionToAuto() {
const blocks = getTopLevelBlocksWithoutDirAttribute()

if (!blocks.length) return null;

blocks.forEach((block) => {
block.setAttribute("dir", "auto")
})
Expand Down Expand Up @@ -59,20 +63,21 @@ function onNotionDocumentLoaded(mutationsList) {
}

function getNotionPageElem(node) {
if (typeof node !== "object") return null
if (typeof node !== 'object') return null
if (!(node instanceof HTMLElement)) return null

let $notionPageElem
for (const rootLevelClassName of ROOT_LEVEL_CLASS_NAMES) {
const $notionPageElem = node.getElementsByClassName(rootLevelClassName)
if ($notionPageElem) return $notionPageElem[0]
$notionPageElem = node.getElementsByClassName(rootLevelClassName)

if ($notionPageElem) {
break
}
}

return null
return $notionPageElem ? $notionPageElem[0] : null
}

// Idle observe changes on notion page then align items, reason we're doing that is we shouldn't
// block any process for the main engine also we don't want to risk the performance when applying
// our styles on large documents.
function idleAlginItemsToRight() {
for (const mutation of MUTATIONS_QUEUE) {
for (const {addedNodes} of mutation) {
Expand Down