We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b6357a1 commit e713d45Copy full SHA for e713d45
lib/codeit.js
@@ -639,8 +639,17 @@ class CodeitElement extends HTMLElement {
639
// wrap the text with matching opening and closing chars
640
const wrappedText = event.key + textToWrap + close[open.indexOf(event.key)];
641
642
+ // delete current selection
643
+ cd.deleteCurrentSelection();
644
+
645
// insert wrapped text
- cd.insert(wrappedText);
646
+ cd.insert(wrappedText, { moveToEnd: false });
647
648
+ // get caret pos in text
649
+ const pos = cd.getSelection();
650
651
+ // restore pos in text
652
+ cd.setSelection(pos.start, (pos.start + wrappedText.length));
653
654
} else {
655
0 commit comments