Skip to content

Commit 0b0abdb

Browse files
authored
Merge pull request #7 from adrianmarinwork/main
fixed issue #2 - paragraphs offset
2 parents 560b654 + 327926a commit 0b0abdb

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/content_script.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,25 @@ function downloadThread({ as = Format.PNG } = {}) {
7070
const pixelRatio = window.devicePixelRatio;
7171
const minRatio = as === Format.PDF ? 2 : 2.5;
7272
window.devicePixelRatio = Math.max(pixelRatio, minRatio);
73-
html2canvas(elements.thread, {
74-
letterRendering: true,
75-
}).then(async function (canvas) {
73+
html2canvas(elements.thread,
74+
{
75+
letterRendering: true,
76+
onclone: function (cloneDoc) {
77+
//Make small fix of position to all the text containers
78+
let listOfTexts = cloneDoc.getElementsByClassName('min-h-[20px]');
79+
Array.from(listOfTexts).forEach((text) => {
80+
text.style.position = 'relative';
81+
text.style.top = '-8px';
82+
});
83+
84+
//Delete copy button from code blocks
85+
let listOfCopyBtns = cloneDoc.querySelectorAll('button.flex');
86+
Array.from(listOfCopyBtns).forEach(
87+
(btn) => (btn.remove())
88+
);
89+
}
90+
}
91+
).then(async function (canvas) {
7692
elements.restoreLocation();
7793
window.devicePixelRatio = pixelRatio;
7894
const imgData = canvas.toDataURL("image/png");

0 commit comments

Comments
 (0)