on import, fall back to setting language from file extension

pull/1/head
ansuz 8 years ago
parent deb63d2447
commit 043041523f

@ -293,11 +293,19 @@ define([
.text(Messages.importButton)
.addClass('rightside-button')
.click(Cryptpad.importContent('text/plain', function (content, file) {
var mode;
var mime = CodeMirror.findModeByMIME(file.type);
var mode = mime && mime.mode || null;
if (!mime) {
var ext = /.+\.([^.]+)$/.exec(val);
if (ext[1]) {
mode = CodeMirror.findModeByExtension(ext[1]);
}
} else {
mode = mime && mime.mode || null;
}
if (Modes.list.some(function (o) { return o.mode === mode; })) {
if (mode && Modes.list.some(function (o) { return o.mode === mode; })) {
setMode(mode);
$bar.find('#language-mode').val(mode);
} else {

Loading…
Cancel
Save