Skip to content

Commit 01988f6

Browse files
committed
Update codeit.js
1 parent ee88ffc commit 01988f6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/codeit.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,21 +408,25 @@ class CodeitElement extends HTMLElement {
408408

409409
const selection = window.getSelection();
410410
if (!selection.rangeCount) return false;
411+
selection.deleteFromDocument();
411412

412-
// if selecting codeit element itself
413+
selection.getRangeAt(0).insertNode(document.createTextNode(paste));
414+
415+
/*// if selecting codeit element itself
413416
if (selection.baseNode === cd) {
414417
415418
// insert newline
416419
cd.insert('\r');
417420
418-
}
421+
}*/
419422

420-
if (hashCode(paste) === hashCode(cd.textContent)) {
421-
422-
e.preventDefault();
423+
/* if (hashCode(paste) === hashCode(cd.textContent)) {
424+
423425
selection.getRangeAt(0).collapse();
424426
425-
}
427+
}*/
428+
429+
event.preventDefault();
426430

427431
});
428432

0 commit comments

Comments
 (0)