(file, i)
| 3850 | if (files && files.length && window.FileReader && window.File) { |
| 3851 | var n = files.length, text = Array(n), read = 0; |
| 3852 | var loadFile = function(file, i) { |
| 3853 | if (cm.options.allowDropFileTypes && |
| 3854 | indexOf(cm.options.allowDropFileTypes, file.type) == -1) |
| 3855 | return; |
| 3856 | |
| 3857 | var reader = new FileReader; |
| 3858 | reader.onload = operation(cm, function() { |
| 3859 | var content = reader.result; |
| 3860 | if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = ""; |
| 3861 | text[i] = content; |
| 3862 | if (++read == n) { |
| 3863 | pos = clipPos(cm.doc, pos); |
| 3864 | var change = {from: pos, to: pos, |
| 3865 | text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())), |
| 3866 | origin: "paste"}; |
| 3867 | makeChange(cm.doc, change); |
| 3868 | setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); |
| 3869 | } |
| 3870 | }); |
| 3871 | reader.readAsText(file); |
| 3872 | }; |
| 3873 | for (var i = 0; i < n; ++i) loadFile(files[i], i); |
| 3874 | } else { // Normal drop |
| 3875 | // Don't do a replace if the drop happened inside of the selected text. |
no test coverage detected