(e)
| 12058 | }) |
| 12059 | |
| 12060 | function onCopyCut(e) { |
| 12061 | if (signalDOMEvent(cm, e)) { |
| 12062 | return |
| 12063 | } |
| 12064 | if (cm.somethingSelected()) { |
| 12065 | setLastCopied({ lineWise: false, text: cm.getSelections() }) |
| 12066 | if (e.type == "cut") { |
| 12067 | cm.replaceSelection("", null, "cut") |
| 12068 | } |
| 12069 | } else if (!cm.options.lineWiseCopyCut) { |
| 12070 | return |
| 12071 | } else { |
| 12072 | var ranges = copyableRanges(cm) |
| 12073 | setLastCopied({ lineWise: true, text: ranges.text }) |
| 12074 | if (e.type == "cut") { |
| 12075 | cm.operation(function () { |
| 12076 | cm.setSelections(ranges.ranges, 0, sel_dontScroll) |
| 12077 | cm.replaceSelection("", null, "cut") |
| 12078 | }) |
| 12079 | } |
| 12080 | } |
| 12081 | if (e.clipboardData) { |
| 12082 | e.clipboardData.clearData() |
| 12083 | var content = lastCopied.text.join("\n") |
| 12084 | // iOS exposes the clipboard API, but seems to discard content inserted into it |
| 12085 | e.clipboardData.setData("Text", content) |
| 12086 | if (e.clipboardData.getData("Text") == content) { |
| 12087 | e.preventDefault() |
| 12088 | return |
| 12089 | } |
| 12090 | } |
| 12091 | // Old-fashioned briefly-focus-a-textarea hack |
| 12092 | var kludge = hiddenTextarea(), |
| 12093 | te = kludge.firstChild |
| 12094 | cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild) |
| 12095 | te.value = lastCopied.text.join("\n") |
| 12096 | var hadFocus = document.activeElement |
| 12097 | selectInput(te) |
| 12098 | setTimeout(function () { |
| 12099 | cm.display.lineSpace.removeChild(kludge) |
| 12100 | hadFocus.focus() |
| 12101 | if (hadFocus == div) { |
| 12102 | input.showPrimarySelection() |
| 12103 | } |
| 12104 | }, 50) |
| 12105 | } |
| 12106 | on(div, "copy", onCopyCut) |
| 12107 | on(div, "cut", onCopyCut) |
| 12108 | } |
nothing calls this directly
no test coverage detected