handle files without extensions when importing into the code editor
This commit is contained in:
parent
4156b1988f
commit
8193a1997c
@ -363,7 +363,15 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
framework.setFileExporter(CodeMirror.getContentExtension, CodeMirror.fileExporter);
|
framework.setFileExporter(CodeMirror.getContentExtension, CodeMirror.fileExporter);
|
||||||
framework.setFileImporter({}, CodeMirror.fileImporter);
|
framework.setFileImporter({}, function () {
|
||||||
|
/* setFileImporter currently takes a function with the following signature:
|
||||||
|
(content, file) => {}
|
||||||
|
I used 'apply' with 'arguments' to avoid breaking things if this API ever changes.
|
||||||
|
*/
|
||||||
|
var ret = CodeMirror.fileImporter.apply(null, Array.prototype.slice.call(arguments));
|
||||||
|
previewPane.modeChange(ret.mode);
|
||||||
|
return ret;
|
||||||
|
});
|
||||||
|
|
||||||
framework.setNormalizer(function (c) {
|
framework.setNormalizer(function (c) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -323,7 +323,7 @@ define([
|
|||||||
var mode;
|
var mode;
|
||||||
if (!mime) {
|
if (!mime) {
|
||||||
var ext = /.+\.([^.]+)$/.exec(file.name);
|
var ext = /.+\.([^.]+)$/.exec(file.name);
|
||||||
if (ext[1]) {
|
if (ext && ext[1]) {
|
||||||
mode = CMeditor.findModeByExtension(ext[1]);
|
mode = CMeditor.findModeByExtension(ext[1]);
|
||||||
mode = mode && mode.mode || null;
|
mode = mode && mode.mode || null;
|
||||||
}
|
}
|
||||||
@ -339,7 +339,8 @@ define([
|
|||||||
exp.setMode('text');
|
exp.setMode('text');
|
||||||
$toolbarContainer.find('#language-mode').val('text');
|
$toolbarContainer.find('#language-mode').val('text');
|
||||||
}
|
}
|
||||||
return { content: content };
|
// return the mode so that the code editor can decide how to display the new content
|
||||||
|
return { content: content, mode: mode };
|
||||||
};
|
};
|
||||||
|
|
||||||
exp.setValueAndCursor = function (oldDoc, remoteDoc) {
|
exp.setValueAndCursor = function (oldDoc, remoteDoc) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user