Skip to content

Commit d8a39bd

Browse files
committed
Update utils.js
1 parent b75c321 commit d8a39bd

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

utils.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,23 @@ Element.prototype.on = (events, callback, passive) => {
739739
}
740740

741741

742-
// focus cursor to end of element
743-
let focusCursorToEnd = (el) => {
742+
// caret
743+
744+
// select all of element
745+
let selectAllCaret = (el) => {
746+
747+
// focus element
748+
el.focus();
749+
750+
const s = window.getSelection();
751+
752+
// select all
753+
s.selectAllChildren(el);
754+
755+
}
756+
757+
// focus caret to end of element
758+
let focusCaretToEnd = (el) => {
744759

745760
// focus element
746761
el.focus();
@@ -750,7 +765,7 @@ let focusCursorToEnd = (el) => {
750765
// if child nodes exist
751766
if (nodes.length !== 0) {
752767

753-
// move cursor to end of input
768+
// move caret to end of input
754769
const s = window.getSelection();
755770
s.setBaseAndExtent(nodes[0], nodes[0].length, nodes[0], nodes[0].length);
756771

0 commit comments

Comments
 (0)