Skip to content

Commit cfd4611

Browse files
committed
Update codeit.js
1 parent 0a80500 commit cfd4611

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/codeit.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,14 +396,16 @@ class CodeitElement extends HTMLElement {
396396

397397
const selection = window.getSelection();
398398
if (!selection.rangeCount) return false;
399-
selection.deleteFromDocument();
400-
399+
401400
const text = window.getSelection().toString();
402401
e.clipboardData.setData('text/plain', text);
403-
e.preventDefault();
402+
403+
cd.deleteCurrentSelection();
404404

405405
cd.dispatchEvent(typeEvent);
406406

407+
e.preventDefault();
408+
407409
});
408410

409411
cd.on('copy', (e) => {

0 commit comments

Comments
 (0)