From 4b73e0da803745553a9a59491596222f92100e85 Mon Sep 17 00:00:00 2001 From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com> Date: Sat, 10 Feb 2024 13:18:18 +0200 Subject: [PATCH] Add preview buttons for markdown and HTML files --- renderer.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/renderer.js b/renderer.js index 522c5d4..2eff279 100644 --- a/renderer.js +++ b/renderer.js @@ -1137,6 +1137,32 @@ previewMDorHTML.addEventListener('click', () => { } }) +previewmdButton.addEventListener('click', () => { + if (currentFilePath === null) { + openModal(unsavedFile) + return + } + if (changes.textContent === 'Unsaved Changes') { + openModal(unsavedFile) + return + } + // Ignore file extension + ipcRenderer.send('previewinwindow', applyMDTemplate(editorTextarea.value)) +}) + +previewhtmlButton.addEventListener('click', () => { + if (currentFilePath === null) { + openModal(unsavedFile) + return + } + if (changes.textContent === 'Unsaved Changes') { + openModal(unsavedFile) + return + } + // Ignore file extension + ipcRenderer.send('previewinwindow', applyHTMLTemplate(editorTextarea.value)) +}) + toggleFullScreenButton.addEventListener('click', () => { toggleFullScreen() })