From e9691ae206c925639fc0c0b963c428d6c87ba660 Mon Sep 17 00:00:00 2001 From: Alexey Leshchenko Date: Fri, 21 May 2021 08:12:49 +0300 Subject: [PATCH 1/3] Fixes the iOS extra image bottom padding issue (cherry picked from commit 3206d61ee1ef92c41480c178a29eddeb3de7594f) --- bundles/loconotion.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bundles/loconotion.js b/bundles/loconotion.js index af56fb7..93ce907 100644 --- a/bundles/loconotion.js +++ b/bundles/loconotion.js @@ -86,3 +86,12 @@ for (let i = 0; i < anchorLinks.length; i++) { }); }); } + +// fix the problem with images having an annoying extra padding +// in Webkit renderers on iOS devices + +const imgs = document.getElementsByTagName("img"); + +for (let i = 0; i < imgs.length; i++) { + imgs[i].parentElement.setAttribute("style", "height:auto!important;"); +} \ No newline at end of file From d8e5c9b351d40fc8dfbabe445580614aaa885611 Mon Sep 17 00:00:00 2001 From: Alexey Leshchenko Date: Fri, 21 May 2021 09:16:55 +0300 Subject: [PATCH 2/3] Exclude emojis + Append styles instead of overwriting --- bundles/loconotion.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bundles/loconotion.js b/bundles/loconotion.js index 93ce907..f836211 100644 --- a/bundles/loconotion.js +++ b/bundles/loconotion.js @@ -90,8 +90,9 @@ for (let i = 0; i < anchorLinks.length; i++) { // fix the problem with images having an annoying extra padding // in Webkit renderers on iOS devices -const imgs = document.getElementsByTagName("img"); +const imgs = document.querySelectorAll("img:not(.notion-emoji)"); for (let i = 0; i < imgs.length; i++) { - imgs[i].parentElement.setAttribute("style", "height:auto!important;"); -} \ No newline at end of file + parent = imgs[i].parentElement + parent.setAttribute("style", parent.getAttribute("style") + "; height:auto!important;"); +} From 9c5a0d7aacd41f73ff26b4b4b1a9a4feb9513ce8 Mon Sep 17 00:00:00 2001 From: Alexey Leshchenko Date: Tue, 10 Aug 2021 22:25:52 +0300 Subject: [PATCH 3/3] Fix excess padding below images --- bundles/loconotion.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bundles/loconotion.js b/bundles/loconotion.js index f836211..ff56f38 100644 --- a/bundles/loconotion.js +++ b/bundles/loconotion.js @@ -94,5 +94,8 @@ const imgs = document.querySelectorAll("img:not(.notion-emoji)"); for (let i = 0; i < imgs.length; i++) { parent = imgs[i].parentElement - parent.setAttribute("style", parent.getAttribute("style") + "; height:auto!important;"); + let style = parent.getAttribute("style") + style = style.replace(/padding-bottom: 133\.333\%;/, "") + style = style + "; height:auto!important;" + parent.setAttribute("style", style); }