mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-05 18:48:41 +00:00
feat: refactor drag and drop file handling to update syntax selection conditionally
This commit is contained in:
@@ -216,12 +216,6 @@
|
||||
const file = e.dataTransfer?.files[0];
|
||||
if (!file) return;
|
||||
|
||||
const syntax = syntaxFromExtension(file.name.split('.').pop() || '');
|
||||
if (syntax && selectedSyntax !== syntax) {
|
||||
selectedSyntax = syntax;
|
||||
}
|
||||
title = file.name;
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = (e) => {
|
||||
@@ -234,6 +228,14 @@
|
||||
}, 5000);
|
||||
return;
|
||||
}
|
||||
const syntax = syntaxFromExtension(file.name.split('.').pop() || '');
|
||||
if (syntax && selectedSyntax !== syntax) {
|
||||
selectedSyntax = syntax;
|
||||
}
|
||||
else (!syntax && selectedSyntax !== 'plaintext') {
|
||||
selectedSyntax = 'plaintext';
|
||||
}
|
||||
title = file.name;
|
||||
const decoder = new TextDecoder();
|
||||
content = decoder.decode(arrayBuffer);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user