Skip to content

Commit

Permalink
[cmd:edit] support to DataURI scheme of text files
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Aug 21, 2017
1 parent 2c6619e commit 8108d59
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/commands/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ elFinder.prototype.commands.edit = function() {
}

req.done(function(data) {
var selEncoding;
var selEncoding, reg, m;
if (data.doconv) {
fm.confirm({
title : self.title,
Expand Down Expand Up @@ -439,6 +439,12 @@ elFinder.prototype.commands.edit = function() {
}
});
} else {
if (file.mime.indexOf('text/') === 0 || $.inArray(file.mime, texts) !== -1) {
reg = new RegExp('^(data:'+file.mime.replace(/([.+])/g, '\\$1')+';base64,)', 'i');
if (window.atob && (m = data.content.match(reg))) {
data.content = atob(data.content.substr(m[1].length));
}
}
dialog(id, file, data.content, data.encoding, editor)
.done(function(data) {
dfrd.resolve(data);
Expand Down

0 comments on commit 8108d59

Please sign in to comment.