(e)
| 1660 | } |
| 1661 | |
| 1662 | function onDrop(e) { |
| 1663 | var cm = this; |
| 1664 | if (eventInWidget(cm.display, e) || (cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e)))) |
| 1665 | return; |
| 1666 | e_preventDefault(e); |
| 1667 | var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; |
| 1668 | if (!pos || isReadOnly(cm)) return; |
| 1669 | if (files && files.length && window.FileReader && window.File) { |
| 1670 | var n = files.length, text = Array(n), read = 0; |
| 1671 | var loadFile = function(file, i) { |
| 1672 | var reader = new FileReader; |
| 1673 | reader.onload = function() { |
| 1674 | text[i] = reader.result; |
| 1675 | if (++read == n) { |
| 1676 | pos = clipPos(cm.doc, pos); |
| 1677 | replaceRange(cm.doc, text.join(""), pos, "around", "paste"); |
| 1678 | } |
| 1679 | }; |
| 1680 | reader.readAsText(file); |
| 1681 | }; |
| 1682 | for (var i = 0; i < n; ++i) loadFile(files[i], i); |
| 1683 | } else { |
| 1684 | // Don't do a replace if the drop happened inside of the selected text. |
| 1685 | if (cm.state.draggingText && !(posLess(pos, cm.doc.sel.from) || posLess(cm.doc.sel.to, pos))) { |
| 1686 | cm.state.draggingText(e); |
| 1687 | // Ensure the editor is re-focused |
| 1688 | setTimeout(bind(focusInput, cm), 20); |
| 1689 | return; |
| 1690 | } |
| 1691 | try { |
| 1692 | var text = e.dataTransfer.getData("Text"); |
| 1693 | if (text) { |
| 1694 | var curFrom = cm.doc.sel.from, curTo = cm.doc.sel.to; |
| 1695 | setSelection(cm.doc, pos, pos); |
| 1696 | if (cm.state.draggingText) replaceRange(cm.doc, "", curFrom, curTo, "paste"); |
| 1697 | cm.replaceSelection(text, null, "paste"); |
| 1698 | focusInput(cm); |
| 1699 | onFocus(cm); |
| 1700 | } |
| 1701 | } |
| 1702 | catch(e){} |
| 1703 | } |
| 1704 | } |
| 1705 | |
| 1706 | function clickInGutter(cm, e) { |
| 1707 | var display = cm.display; |
nothing calls this directly
no test coverage detected