Skip to content

Commit 4a7f66f

Browse files
authored
fix: disable file opening in browser (Dun-sin#405)
* disable file opening in browser * refactored
1 parent 8f3ad5a commit 4a7f66f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ const dropDownElements = document.querySelectorAll('.dropdown');
121121
const getDegreeElement = getRange('animation');
122122
const getRadioButtonSetElement = getRadioButtonSet('animation');
123123
const getDurationElement = getInputSpinner('animation');
124+
const events = ["dragover", "drop"];
125+
124126
if (openSidePanelButton) {
125127
openSidePanelButton.style.display = 'none';
126128
}
@@ -306,7 +308,7 @@ function showOpenPreviousResultText() {
306308
getOpenPreviousResult.style.animationFillMode = 'backwards';
307309
}
308310

309-
// clicking outside the nav bar should close the nav abr
311+
// clicking outside the nav bar should close the nav bar
310312
document.addEventListener('click', (e: Event) => {
311313
const event = e.target as HTMLElement;
312314

@@ -330,6 +332,13 @@ document.addEventListener('click', (e: Event) => {
330332
}
331333
});
332334

335+
// Disable file opening in browser
336+
for ( let event of events) {
337+
document.addEventListener(event, (e) => {
338+
e.preventDefault();
339+
})
340+
}
341+
333342
// clicking on the menu icon should close the nav bar
334343
menuIcon?.addEventListener('click', () => {
335344
if (navBar?.classList.contains('closed-nav')) {

0 commit comments

Comments
 (0)