Compare commits

..

No commits in common. "e25f2db188e82c7aad22b6ddbb270f2dbf5b2aa9" and "f2128fbf10ae332328bbd2644ecaca179ac41622" have entirely different histories.

6 changed files with 60 additions and 50 deletions

View File

@ -1,15 +1,26 @@
/** /**
* notion-enhancer: right to left * notion-enhancer: right to left
* (c) 2021 obahareth <omar@omar.engineer> (https://omar.engineer) * (c) 2021 obahareth <omar@omar.engineer> (https://omar.engineer)
* (c) 2024 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/) * (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license * (https://notion-enhancer.github.io/) under the MIT license
*/ */
/* indent rtl toc header levels, .notion-page-content
* https://github.com/notion-enhancer/notion-enhancer/issues/616 */ .notion-table_of_contents-block
.notion-table_of_contents-block div[style*="margin-left: 24px"] { > div
> div
> a
> div
> div[style*='margin-left: 24px'] {
margin-inline-start: 24px; margin-inline-start: 24px;
} }
.notion-table_of_contents-block div[style*="margin-left: 48px"] {
.notion-page-content
.notion-table_of_contents-block
> div
> div
> a
> div
> div[style*='margin-left: 48px'] {
margin-inline-start: 48px; margin-inline-start: 48px;
} }

View File

@ -1,52 +1,50 @@
/** /**
* notion-enhancer: right to left * notion-enhancer: right to left
* (c) 2021 obahareth <omar@omar.engineer> (https://omar.engineer) * (c) 2021 obahareth <omar@omar.engineer> (https://omar.engineer)
* (c) 2024 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/) * (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license * (https://notion-enhancer.github.io/) under the MIT license
*/ */
export default async (api) => { 'use strict';
const { addMutationListener } = api,
pageContentSelector = ` export default async function ({ web }, db) {
:is([placeholder="Untitled"], const pageContentSelector = `
.notion-page-content :is( .notion-page-content >
div[data-block-id]:not(.notion-column_list-block, div[data-block-id]:not([dir]):not(.notion-column_list-block):not(.notion-collection_view_page-block),
.notion-collection_view_page-block, .notion-header-block, [placeholder="Untitled"]:not([dir]),
.notion-sub_header-block, .notion-sub_sub_header-block .notion-column-block > div[data-block-id]:not([dir]),
.notion-toggle-block, .notion-table_of_contents-block), .notion-collection_view-block:not([dir]),
.notion-header-block [placeholder="Heading 1"], .notion-table-view:not([dir]),
.notion-sub_header-block [placeholder="Heading 2"], .notion-board-view:not([dir]),
.notion-sub_sub_header-block [placeholder="Heading 3"], .notion-gallery-view:not([dir])`,
.notion-toggle-block [placeholder="Toggle"], listItemSelector = `
.notion-table_of_contents-block a), div[placeholder="List"]:not([style*="text-align: start"]),
.notion-page-view-discussion [data-content-editable-leaf], div[placeholder="To-do"]:not([style*="text-align: start"]),
.notion-table-view-header-cell, .notion-table-view-cell, div[placeholder="Toggle"]:not([style*="text-align: start"])`,
.notion-board-view, .notion-gallery-view):not([dir])`,
listItemSelector = `:is(div[placeholder="List"], div[placeholder="To-do"],
div[placeholder="Toggle"]):not([style*="text-align: start"])`,
inlineEquationSelector = inlineEquationSelector =
'.notion-text-equation-token .katex-html:not([style*="direction: rtl;"])'; '.notion-text-equation-token .katex-html:not([style*="direction: rtl;"])';
const autoAlignText = () => { const autoAlignText = () => {
document document
.querySelectorAll(pageContentSelector) .querySelectorAll(pageContentSelector)
.forEach(($block) => $block.setAttribute("dir", "auto")); .forEach(($block) => $block.setAttribute('dir', 'auto'));
document.querySelectorAll(listItemSelector).forEach(($item) => { document.querySelectorAll(listItemSelector).forEach(($item) => {
$item.style["text-align"] = "start"; $item.style['text-align'] = 'start';
}); });
document.querySelectorAll(inlineEquationSelector).forEach(($equation) => { document.querySelectorAll(inlineEquationSelector).forEach(($equation) => {
$equation.style.direction = "rtl"; $equation.style.direction = 'rtl';
$equation.style.display = "inline-flex"; $equation.style.display = 'inline-flex';
$equation.style.flexDirection = "row-reverse"; $equation.style.flexDirection = 'row-reverse';
for (const $symbol of $equation.children) { for (const $symbol of $equation.children) {
$symbol.style.direction = "ltr"; $symbol.style.direction = 'ltr';
} }
}); });
}; };
web.addDocumentObserver(autoAlignText, [
const textareas = [
pageContentSelector, pageContentSelector,
listItemSelector, listItemSelector,
inlineEquationSelector, inlineEquationSelector,
].join(","); ]);
addMutationListener(textareas, autoAlignText); await web.whenReady();
}; autoAlignText();
}

View File

@ -1,21 +1,23 @@
{ {
"name": "Right To Left", "name": "right to left",
"version": "1.5.0",
"id": "b28ee2b9-4d34-4e36-be8a-ab5be3d79f51", "id": "b28ee2b9-4d34-4e36-be8a-ab5be3d79f51",
"description": "Enables automatic writing direction detection for languages that read right-to-left.", "version": "1.5.0",
"tags": ["rtl", "language-support"], "description": "enables auto rtl/ltr text direction detection.",
"preview": "right-to-left.jpg",
"tags": ["extension", "usability"],
"authors": [ "authors": [
{
"name": "dragonwocky",
"homepage": "https://dragonwocky.me/",
"avatar": "https://dragonwocky.me/avatar.jpg"
},
{ {
"name": "obahareth", "name": "obahareth",
"email": "omar@omar.engineer",
"homepage": "https://omar.engineer", "homepage": "https://omar.engineer",
"avatar": "https://avatars.githubusercontent.com/u/3428118" "avatar": "https://avatars.githubusercontent.com/u/3428118"
} }
], ],
"clientStyles": ["client.css"], "js": {
"clientScripts": ["client.mjs"] "client": ["client.mjs"]
},
"css": {
"client": ["client.css"]
},
"options": []
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -43,8 +43,8 @@ export default async (api, db) => {
const updateStats = debounce(() => { const updateStats = debounce(() => {
if (!document.contains($page)) $page = document.querySelector(page); if (!document.contains($page)) $page = document.querySelector(page);
if (!$page) return; if (!$page) return;
const text = $page.innerText.trim(), const text = $page.innerText,
words = text.length ? text.split(/\s+/).length : 0, words = text.split(/[^\w]+/).length,
sentences = text.split(".").filter((s) => s.trim()).length, sentences = text.split(".").filter((s) => s.trim()).length,
blocks = $page.querySelectorAll("[data-block-id]").length; blocks = $page.querySelectorAll("[data-block-id]").length;
$wordCount.setCount(words); $wordCount.setCount(words);

View File

@ -7,7 +7,6 @@
"extensions/outliner", "extensions/outliner",
"extensions/word-counter", "extensions/word-counter",
"extensions/line-numbers", "extensions/line-numbers",
"extensions/right-to-left",
"extensions/no-peeking", "extensions/no-peeking",
"extensions/focus", "extensions/focus",
"themes/classic-dark" "themes/classic-dark"