From b136495a5c1f64f682c9b2081fac468bc42bf049 Mon Sep 17 00:00:00 2001 From: Reorx Date: Sat, 11 Feb 2023 23:38:54 +0800 Subject: [PATCH] editor: add Print the preview button --- src/editor/index.html | 2 ++ src/editor/main.js | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/editor/index.html b/src/editor/index.html index 95bdeba..a35c01e 100644 --- a/src/editor/index.html +++ b/src/editor/index.html @@ -40,6 +40,8 @@

You can first click "Download HTML", then open the HTML in a browser and choose "Print" from the menu (or press ⌘+P), it will open a modal where you should find the option to save it as a PDF.

For best compatibility, I recommend using Firefox rather than Chrome to complete this process.

+

Click the button below to open the print dialog for the preview.

+ diff --git a/src/editor/main.js b/src/editor/main.js index 2c76080..9ae237b 100644 --- a/src/editor/main.js +++ b/src/editor/main.js @@ -23,7 +23,7 @@ import { getCVTitle } from '../themes/data'; import { registerIconLib } from './je-iconlib'; import { registerTheme } from './je-theme'; -const propertiesInOrder = ['basics', 'education', 'work', 'projects', 'sideProjects', 'skills', 'languages', 'interests', 'references', 'awards', 'publications', 'volunteer', 'meta'] +const propertiesInOrder = ['basics', 'education', 'work', 'projects', 'sideProjects', 'skills', 'languages', 'interests', 'references', 'awards', 'publications', 'volunteer', 'certificates', 'meta'] const basicsPropertiesInOrder = ['name', 'label', 'email', 'phone', 'url', 'summary', 'image', 'location', 'profiles'] // toc elements @@ -160,6 +160,7 @@ const $inputUploadData = $('input[name=upload-data]') const $btnDownloadJSON = $('#fn-download-json') const $btnDownloadHTML = $('#fn-download-html') const $btnLoadSample = $('#fn-load-sample') +const $btnPrintPreview = $('#fn-print-preview') $btnShowPreview.on('click', () => { $outputJSON.hide() @@ -238,3 +239,7 @@ $btnLoadSample.on('click', () => { editor.setValue(sampleModule.default) }) + +$btnPrintPreview.on('click', () => { + $outputHTML.get(0).contentWindow.print() +})