Align implementation with @yaisog's suggestion

See https://github.com/Jermolene/TiddlyWiki5/pull/7222#issuecomment-1410194593
This commit is contained in:
jeremy@jermolene.com
2023-02-23 22:05:57 +00:00
parent 41bd824022
commit 3262b8d77d
5 changed files with 9 additions and 17 deletions
+3 -12
View File
@@ -40,19 +40,10 @@ exports.setSelectionRangeSafe = function(node,start,end,direction) {
};
/*
Select the text in an input or textarea by keyword:
start - place cursor at start of text
end|no - place cursor at end of text
yes - select entire text
Select the text in an input or textarea by position
*/
exports.setSelectionByKeyword = function(node,selectType) {
if(selectType === "start") {
$tw.utils.setSelectionRangeSafe(node,0,0);
} else if(selectType === "end" || selectType === "no") {
$tw.utils.setSelectionRangeSafe(node,node.value.length,node.value.length);
} else {
node.select();
}
exports.setSelectionByPosition = function(node,selectFromStart,selectFromEnd) {
$tw.utils.setSelectionRangeSafe(node,selectFromStart,node.value.length - selectFromEnd);
};
exports.removeChildren = function(node) {