Skip to content

Commit

Permalink
chore: add import button
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj36 committed Dec 5, 2024
1 parent 66a38f2 commit 9979810
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const saveSourceBtn = document.getElementById('save-source');
const previousSlide = document.getElementById('previous-slide');
const nextSlide = document.getElementById('next-slide');
const _u = window.md2slides;
const importMdBtn = document.getElementById('import-md');

let activeIndex = 0;

Expand Down Expand Up @@ -142,3 +143,21 @@ function getCurrentSlideIndex() {
outputEl.addEventListener('scroll', () => {
activeIndex = getCurrentSlideIndex();
});

importMdBtn.addEventListener('click', () => {
const input = document.createElement('input');
input.type = 'file';
input.accept = '.md';
input.onchange = (event) => {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = (e) => {
sourceEl.value = e.target.result;
updateOutput();
};
reader.readAsText(file);
}
};
input.click();
});
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</div>

<div id="buttons">
<button id="import-md">📂 Import .md</button>
<button id="save-source">💾 Save as .md</button>
<button id="previous-slide">← Previous</button>
<button id="next-slide">Next →</button>
Expand Down

0 comments on commit 9979810

Please sign in to comment.