(e)
| 1901 | var lastDrop = 0; |
| 1902 | |
| 1903 | function onDrop(e) { |
| 1904 | var cm = this; |
| 1905 | if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e) || (cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e)))) |
| 1906 | return; |
| 1907 | e_preventDefault(e); |
| 1908 | if (ie) lastDrop = +new Date; |
| 1909 | var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; |
| 1910 | if (!pos || isReadOnly(cm)) return; |
| 1911 | if (files && files.length && window.FileReader && window.File) { |
| 1912 | var n = files.length, text = Array(n), read = 0; |
| 1913 | var loadFile = function(file, i) { |
| 1914 | var reader = new FileReader; |
| 1915 | reader.onload = function() { |
| 1916 | text[i] = reader.result; |
| 1917 | if (++read == n) { |
| 1918 | pos = clipPos(cm.doc, pos); |
| 1919 | makeChange(cm.doc, {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"}, "around"); |
| 1920 | } |
| 1921 | }; |
| 1922 | reader.readAsText(file); |
| 1923 | }; |
| 1924 | for (var i = 0; i < n; ++i) loadFile(files[i], i); |
| 1925 | } else { |
| 1926 | // Don't do a replace if the drop happened inside of the selected text. |
| 1927 | if (cm.state.draggingText && !(posLess(pos, cm.doc.sel.from) || posLess(cm.doc.sel.to, pos))) { |
| 1928 | cm.state.draggingText(e); |
| 1929 | // Ensure the editor is re-focused |
| 1930 | setTimeout(bind(focusInput, cm), 20); |
| 1931 | return; |
| 1932 | } |
| 1933 | try { |
| 1934 | var text = e.dataTransfer.getData("Text"); |
| 1935 | if (text) { |
| 1936 | var curFrom = cm.doc.sel.from, curTo = cm.doc.sel.to; |
| 1937 | setSelection(cm.doc, pos, pos); |
| 1938 | if (cm.state.draggingText) replaceRange(cm.doc, "", curFrom, curTo, "paste"); |
| 1939 | cm.replaceSelection(text, null, "paste"); |
| 1940 | focusInput(cm); |
| 1941 | } |
| 1942 | } |
| 1943 | catch(e){} |
| 1944 | } |
| 1945 | } |
| 1946 | |
| 1947 | function onDragStart(cm, e) { |
| 1948 | if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; } |
nothing calls this directly
no test coverage detected