Skip to content

Commit 437e27b

Browse files
committed
feat(dev): Use body class to control styles setup instead of bundle config.
1 parent 0ce6d31 commit 437e27b

14 files changed

+161
-75
lines changed

assets/obsidian-styles.txt.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/obsidian-styles.txt.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/plugin-styles.txt.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/plugin-styles.txt.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/src/obsidian-styles.txt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import './obsidian-styles.txt.css';
1+
import './obsidian-styles.txt.scss';

assets/src/plugin-styles.txt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import './plugin-styles.txt.css'
1+
import './plugin-styles.txt.scss'

assets/src/plugin-styles.txt.css renamed to assets/src/plugin-styles.txt.scss

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,3 +1098,32 @@ hr
10981098
color: var(--text-faint);
10991099
}
11001100
/*#endregion */
1101+
1102+
1103+
// print styles
1104+
1105+
.printing {
1106+
.sidebar-left, .sidebar-right {
1107+
display: none !important;
1108+
}
1109+
.document-container {
1110+
height: 100%;
1111+
padding-bottom: 0 !important;
1112+
overflow: visible;
1113+
}
1114+
.document-container .markdown-preview-view {
1115+
padding: unset;
1116+
overflow: visible;
1117+
height: 100%;
1118+
}
1119+
.webpage-container {
1120+
overflow: scroll;
1121+
}
1122+
.markdown-preview-section {
1123+
position: relative !important;
1124+
}
1125+
.markdown-preview-section .site-footer {
1126+
position: absolute;
1127+
width: 100%;
1128+
}
1129+
}

assets/src/webpage.txt.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -573,35 +573,6 @@ function formatPage() {
573573
}
574574

575575
function printAsPNG() {
576-
// Add CSS styles for print layout
577-
const styles = `
578-
<style>
579-
.sidebar-left, .sidebar-right {
580-
display: none !important;
581-
}
582-
.document-container {
583-
height: 100%;
584-
padding-bottom: 0 !important;
585-
overflow: visible;
586-
}
587-
.document-container .markdown-preview-view {
588-
padding: unset;
589-
overflow: visible;
590-
height: 100%;
591-
}
592-
.webpage-container {
593-
overflow: scroll;
594-
}
595-
.markdown-preview-section {
596-
position: relative !important;
597-
}
598-
.markdown-preview-section .site-footer {
599-
position: absolute;
600-
width: 100%;
601-
}
602-
</style>
603-
`;
604-
605576
// Get the HTML content of the current webpage
606577
const htmlContent = document.documentElement.innerHTML;
607578

@@ -610,7 +581,7 @@ function printAsPNG() {
610581

611582
// Write the HTML content and styles to the new window
612583
printWindow.document.open();
613-
printWindow.document.write(styles + htmlContent);
584+
printWindow.document.write(htmlContent);
614585
printWindow.document.close();
615586

616587
// window.toPng = htmlToImage.toPng;
@@ -620,6 +591,7 @@ function printAsPNG() {
620591

621592
printWindow.document.addEventListener('DOMContentLoaded', function() {
622593
console.log('dom loaded');
594+
printWindow.document.body.classList.add('printing');
623595
const contentsNode = printWindow.document.body.querySelector('.markdown-preview-section');
624596
const footerNode = printWindow.document.body.querySelector('.site-footer');
625597
if (!contentsNode) {

assets/webpage.txt.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)