mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +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];
|
const file = e.dataTransfer?.files[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
const syntax = syntaxFromExtension(file.name.split('.').pop() || '');
|
|
||||||
if (syntax && selectedSyntax !== syntax) {
|
|
||||||
selectedSyntax = syntax;
|
|
||||||
}
|
|
||||||
title = file.name;
|
|
||||||
|
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
|
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
@@ -234,6 +228,14 @@
|
|||||||
}, 5000);
|
}, 5000);
|
||||||
return;
|
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();
|
const decoder = new TextDecoder();
|
||||||
content = decoder.decode(arrayBuffer);
|
content = decoder.decode(arrayBuffer);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user