MCPcopy
hub / github.com/witheve/Eve / onCopyCut

Function onCopyCut

src/codemirror.js:1623–1657  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

1621 });
1622
1623 function onCopyCut(e) {
1624 if (signalDOMEvent(cm, e)) return
1625 if (cm.somethingSelected()) {
1626 lastCopied = {lineWise: false, text: cm.getSelections()};
1627 if (e.type == "cut") cm.replaceSelection("", null, "cut");
1628 } else if (!cm.options.lineWiseCopyCut) {
1629 return;
1630 } else {
1631 var ranges = copyableRanges(cm);
1632 lastCopied = {lineWise: true, text: ranges.text};
1633 if (e.type == "cut") {
1634 cm.operation(function() {
1635 cm.setSelections(ranges.ranges, 0, sel_dontScroll);
1636 cm.replaceSelection("", null, "cut");
1637 });
1638 }
1639 }
1640 // iOS exposes the clipboard API, but seems to discard content inserted into it
1641 if (e.clipboardData && !ios) {
1642 e.preventDefault();
1643 e.clipboardData.clearData();
1644 e.clipboardData.setData("text/plain", lastCopied.text.join("\n"));
1645 } else {
1646 // Old-fashioned briefly-focus-a-textarea hack
1647 var kludge = hiddenTextarea(), te = kludge.firstChild;
1648 cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
1649 te.value = lastCopied.text.join("\n");
1650 var hadFocus = document.activeElement;
1651 selectInput(te);
1652 setTimeout(function() {
1653 cm.display.lineSpace.removeChild(kludge);
1654 hadFocus.focus();
1655 }, 50);
1656 }
1657 }
1658 on(div, "copy", onCopyCut);
1659 on(div, "cut", onCopyCut);
1660 },

Callers

nothing calls this directly

Calls 8

signalDOMEventFunction · 0.85
copyableRangesFunction · 0.85
hiddenTextareaFunction · 0.85
selectInputFunction · 0.85
somethingSelectedMethod · 0.80
replaceSelectionMethod · 0.80
operationMethod · 0.80
focusMethod · 0.80

Tested by

no test coverage detected