MCPcopy Index your code
hub / github.com/DHTMLX/gantt / onCopyCut

Function onCopyCut

samples/common/codehighlight/codemirror.js:8807–8845  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

8805 });
8806
8807 function onCopyCut(e) {
8808 if (!belongsToInput(e) || signalDOMEvent(cm, e)) { return }
8809 if (cm.somethingSelected()) {
8810 setLastCopied({lineWise: false, text: cm.getSelections()});
8811 if (e.type == "cut") { cm.replaceSelection("", null, "cut"); }
8812 } else if (!cm.options.lineWiseCopyCut) {
8813 return
8814 } else {
8815 var ranges = copyableRanges(cm);
8816 setLastCopied({lineWise: true, text: ranges.text});
8817 if (e.type == "cut") {
8818 cm.operation(function () {
8819 cm.setSelections(ranges.ranges, 0, sel_dontScroll);
8820 cm.replaceSelection("", null, "cut");
8821 });
8822 }
8823 }
8824 if (e.clipboardData) {
8825 e.clipboardData.clearData();
8826 var content = lastCopied.text.join("\n");
8827 // iOS exposes the clipboard API, but seems to discard content inserted into it
8828 e.clipboardData.setData("Text", content);
8829 if (e.clipboardData.getData("Text") == content) {
8830 e.preventDefault();
8831 return
8832 }
8833 }
8834 // Old-fashioned briefly-focus-a-textarea hack
8835 var kludge = hiddenTextarea(), te = kludge.firstChild;
8836 cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
8837 te.value = lastCopied.text.join("\n");
8838 var hadFocus = activeElt();
8839 selectInput(te);
8840 setTimeout(function () {
8841 cm.display.lineSpace.removeChild(kludge);
8842 hadFocus.focus();
8843 if (hadFocus == div) { input.showPrimarySelection(); }
8844 }, 50);
8845 }
8846 on(div, "copy", onCopyCut);
8847 on(div, "cut", onCopyCut);
8848 };

Callers

nothing calls this directly

Calls 9

belongsToInputFunction · 0.85
signalDOMEventFunction · 0.85
setLastCopiedFunction · 0.85
copyableRangesFunction · 0.85
hiddenTextareaFunction · 0.85
activeEltFunction · 0.85
selectInputFunction · 0.85
focusMethod · 0.65
getDataMethod · 0.45

Tested by

no test coverage detected