Skip to content

Commit 733755e

Browse files
author
Will Bamberg
committed
Handle 'cut'
1 parent a937132 commit 733755e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

editable-samples-2/js/editable.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,19 @@ function onEdit(e) {
5252
applyCode(e.currentTarget.textContent, e.currentTarget.parentNode);
5353
}
5454

55-
document.addEventListener('copy', function(e){
55+
56+
function copyTextOnly(e) {
5657
var selection = window.getSelection();
5758
var range = selection.getRangeAt(0);
5859

5960
e.clipboardData.setData('text/plain', range.toString());
6061
e.clipboardData.setData('text/html', range.toString());
6162
e.preventDefault();
6263
e.stopPropagation();
63-
64-
});
64+
}
65+
66+
document.addEventListener('cut', copyTextOnly);
67+
document.addEventListener('copy', copyTextOnly);
6568

6669
for (exampleChoice of exampleChoices) {
6770
exampleChoice.addEventListener("click", onChoose);

0 commit comments

Comments
 (0)