(file, i)
| 3872 | if (files && files.length && window.FileReader && window.File) { |
| 3873 | var n = files.length, text = Array(n), read = 0; |
| 3874 | var loadFile = function(file, i) { |
| 3875 | if (cm.options.allowDropFileTypes && |
| 3876 | indexOf(cm.options.allowDropFileTypes, file.type) == -1) |
| 3877 | return; |
| 3878 | |
| 3879 | var reader = new FileReader; |
| 3880 | reader.onload = operation(cm, function() { |
| 3881 | var content = reader.result; |
| 3882 | if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = ""; |
| 3883 | text[i] = content; |
| 3884 | if (++read == n) { |
| 3885 | pos = clipPos(cm.doc, pos); |
| 3886 | var change = {from: pos, to: pos, |
| 3887 | text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())), |
| 3888 | origin: "paste"}; |
| 3889 | makeChange(cm.doc, change); |
| 3890 | setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); |
| 3891 | } |
| 3892 | }); |
| 3893 | reader.readAsText(file); |
| 3894 | }; |
| 3895 | for (var i = 0; i < n; ++i) loadFile(files[i], i); |
| 3896 | } else { // Normal drop |
| 3897 | // Don't do a replace if the drop happened inside of the selected text. |
no test coverage detected