Skip to content

Commit

Permalink
minor fix for inline code block
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshj01 committed Oct 8, 2024
1 parent 872ee24 commit d40091c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion public/sw.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ export const downloadImage = async () => {
const preview = document.getElementById('preview');
if (!preview) return;

const codeBlocks = preview.querySelectorAll('code:not(pre code)');

// Add custom class to fix rendering issues
codeBlocks.forEach(block => {
const codeBlock = block as HTMLElement; // Cast to HTMLElement
codeBlock.style.paddingBottom = '1.0em';
// codeBlock.style.backgroundColor = 'red';
// codeBlock.style.display = 'inline-block';
// codeBlock.style.verticalAlign = 'middle';
});

const previewElement = preview.querySelector('.reactMarkDown');
const originalClasses = previewElement!.className;

Expand All @@ -61,6 +72,11 @@ export const downloadImage = async () => {
link.download = 'pastelog.png';
link.href = canvas.toDataURL('image/png');
link.click();
// Restore the original styles after capturing the canvas
codeBlocks.forEach(block => {
const codeBlock = block as HTMLElement; // Cast to HTMLElement
codeBlock.style.paddingBottom = '';
});
previewElement!.className = originalClasses;
}).catch(error => {
previewElement!.className = originalClasses;
Expand Down

0 comments on commit d40091c

Please sign in to comment.