properly align rtl bullet points/checkboxes #55

though more performant, this also limits rtl to page content
This commit is contained in:
dragonwocky 2020-09-17 14:37:04 +10:00
parent dfcac064e8
commit 1a66d769cc
Signed by: dragonwocky
GPG Key ID: C7A48B7846AA706D
3 changed files with 44 additions and 20 deletions

View File

@ -35,6 +35,7 @@ a feature and cleanup update.
- bugfix: block-level text colours are now changed properly. - bugfix: block-level text colours are now changed properly.
- bugfix: do not require data folder during installation, to prevent `sudo` attempting to - bugfix: do not require data folder during installation, to prevent `sudo` attempting to
create it in `/var/root/`. create it in `/var/root/`.
- bugfix: bullet points/checkboxes will now align properly in the right-to-left extension.
- themes: "littlepig" (light + dark) = monospaced themes using emojis and colourful text. - themes: "littlepig" (light + dark) = monospaced themes using emojis and colourful text.
- extension: "font chooser" = customize fonts. for each option, type in the name of the font you would like to use, - extension: "font chooser" = customize fonts. for each option, type in the name of the font you would like to use,
or leave it blank to not change anything. or leave it blank to not change anything.
@ -44,11 +45,6 @@ a feature and cleanup update.
- extension: "hide help button" = hide the help button if you don't need it. - extension: "hide help button" = hide the help button if you don't need it.
- extension: "bypass preview" = go straight to the normal full view when opening a page. - extension: "bypass preview" = go straight to the normal full view when opening a page.
// todo
- bugfix: switch to a different right-to-left extension because it wasn't working right
with bullet points and stuff.
notion-deb-builder has been discovered to not generate an app.asar and so is no longer supported. notion-deb-builder has been discovered to not generate an app.asar and so is no longer supported.
### v0.8.5 (2020-08-29) ### v0.8.5 (2020-08-29)

View File

@ -45,6 +45,12 @@
[style*='pointer-events:'][style*='max-width: 100%; width: 100%'] { [style*='pointer-events:'][style*='max-width: 100%; width: 100%'] {
width: var(--theme--page_full-width) !important; width: var(--theme--page_full-width) !important;
} }
.notion-frame .notion-scroller [style*='padding-left: 136.5px;'] {
padding-left: 0 !important;
}
.notion-frame .notion-scroller [style*='padding-right: 136.5px;'] {
padding-right: 0 !important;
}
.notion-peek-renderer .notion-peek-renderer
.notion-scroller.vertical .notion-scroller.vertical

View File

@ -12,33 +12,55 @@ module.exports = {
tags: ['extension'], tags: ['extension'],
name: 'right-to-left', name: 'right-to-left',
desc: 'enables auto rtl/ltr text direction detection.', desc: 'enables auto rtl/ltr text direction detection.',
version: '1.3.0', version: '1.4.0',
author: 'obahareth', author: 'obahareth',
hacks: { hacks: {
'renderer/preload.js'(store, __exports) { 'renderer/preload.js'(store, __exports) {
function alignPageContentToRight() {
document
.querySelectorAll(
'.notion-page-content > div[data-block-id]:not([dir])'
)
.forEach((block) => block.setAttribute('dir', 'auto'));
document
.querySelectorAll("div[placeholder='List'], div[placeholder='To-do']")
.forEach((item) => {
item.style['text-align'] = '-webkit-auto';
});
}
document.addEventListener('readystatechange', (event) => { document.addEventListener('readystatechange', (event) => {
if (document.readyState !== 'complete') return false; if (document.readyState !== 'complete') return false;
let queue = []; let queue = [];
const observer = new MutationObserver((list, observer) => { const DOCUMENT_OBSERVER = new MutationObserver((list, observer) => {
if (!queue.length) requestAnimationFrame(() => process(queue)); if (!queue.length) requestIdleCallback(() => process(queue));
queue.push(...list); queue.push(...list);
}); }),
observer.observe(document.body, { PAGE_OBSERVER = new MutationObserver(alignPageContentToRight);
DOCUMENT_OBSERVER.observe(document.body, {
childList: true, childList: true,
subtree: true, subtree: true,
characterData: true,
}); });
function process(list) { function process(list) {
queue = []; queue = [];
for (let { target } of list) { for (let { addedNodes } of list) {
if (!target.innerText) continue;
if (target.getAttribute('dir') !== 'auto')
target.setAttribute('dir', 'auto');
if ( if (
getComputedStyle(target).getPropertyValue('text-align') !== addedNodes[0] &&
'start' addedNodes[0].className === 'notion-page-content'
) ) {
target.style.setProperty('text-align', 'start'); alignPageContentToRight();
const $page = document.getElementsByClassName(
'notion-page-content'
)[0];
if ($page) {
PAGE_OBSERVER.disconnect();
PAGE_OBSERVER.observe($page, {
childList: true,
subtree: false,
});
}
}
} }
} }
}); });