diff --git a/index.html b/index.html index afbee53..8bfb3e7 100644 --- a/index.html +++ b/index.html @@ -30,6 +30,7 @@
+ diff --git a/public/css/style.css b/public/css/style.css index 6187a31..89d065c 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -70,6 +70,10 @@ header a:hover { margin-left: 16px; } +#print-button { + margin-left: 16px; +} + #sync-button { margin-left: 16px; -webkit-user-select: none; diff --git a/src/main.js b/src/main.js index 2aa4626..b945992 100644 --- a/src/main.js +++ b/src/main.js @@ -238,6 +238,98 @@ This web site is using ${"`"}markedjs/marked${"`"}. }); }; + let openPrintWindow = () => { + // Get the content from the preview pane + let previewContent = document.querySelector('#output').innerHTML; + + // Get the GitHub markdown CSS + let markdownStyles = ''; + for (let sheet of document.styleSheets) { + if (sheet.href && sheet.href.includes('github-markdown')) { + try { + for (let rule of sheet.cssRules) { + markdownStyles += rule.cssText + '\n'; + } + } catch (e) { + // Handle cross-origin CSS + markdownStyles = `@import url('${sheet.href}');`; + } + break; + } + } + + // Create a new window with the content + let printWindow = window.open('', '_blank', 'width=800,height=600'); + + if (printWindow) { + printWindow.document.write(` + + + + +