(e)
| 8783 | var lastDrop = 0 |
| 8784 | |
| 8785 | function onDrop(e) { |
| 8786 | var cm = this |
| 8787 | clearDragCursor(cm) |
| 8788 | if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { |
| 8789 | return |
| 8790 | } |
| 8791 | e_preventDefault(e) |
| 8792 | if (ie) { |
| 8793 | lastDrop = +new Date() |
| 8794 | } |
| 8795 | var pos = posFromMouse(cm, e, true), |
| 8796 | files = e.dataTransfer.files |
| 8797 | if (!pos || cm.isReadOnly()) { |
| 8798 | return |
| 8799 | } |
| 8800 | // Might be a file drop, in which case we simply extract the text |
| 8801 | // and insert it. |
| 8802 | if (files && files.length && window.FileReader && window.File) { |
| 8803 | var n = files.length, |
| 8804 | text = Array(n), |
| 8805 | read = 0 |
| 8806 | var loadFile = function (file, i) { |
| 8807 | if (cm.options.allowDropFileTypes && indexOf(cm.options.allowDropFileTypes, file.type) == -1) { |
| 8808 | return |
| 8809 | } |
| 8810 | |
| 8811 | var reader = new FileReader() |
| 8812 | reader.onload = operation(cm, function () { |
| 8813 | var content = reader.result |
| 8814 | if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { |
| 8815 | content = "" |
| 8816 | } |
| 8817 | text[i] = content |
| 8818 | if (++read == n) { |
| 8819 | pos = clipPos(cm.doc, pos) |
| 8820 | var change = { from: pos, to: pos, text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())), origin: "paste" } |
| 8821 | makeChange(cm.doc, change) |
| 8822 | setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))) |
| 8823 | } |
| 8824 | }) |
| 8825 | reader.readAsText(file) |
| 8826 | } |
| 8827 | for (var i = 0; i < n; ++i) { |
| 8828 | loadFile(files[i], i) |
| 8829 | } |
| 8830 | } else { |
| 8831 | // Normal drop |
| 8832 | // Don't do a replace if the drop happened inside of the selected text. |
| 8833 | if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { |
| 8834 | cm.state.draggingText(e) |
| 8835 | // Ensure the editor is re-focused |
| 8836 | setTimeout(function () { |
| 8837 | return cm.display.input.focus() |
| 8838 | }, 20) |
| 8839 | return |
| 8840 | } |
| 8841 | try { |
| 8842 | var text$1 = e.dataTransfer.getData("Text") |
nothing calls this directly
no test coverage detected