mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-04 13:19:11 +00:00
Align implementation with @yaisog's suggestion
See https://github.com/Jermolene/TiddlyWiki5/pull/7222#issuecomment-1410194593
This commit is contained in:
parent
41bd824022
commit
3262b8d77d
@ -181,7 +181,7 @@ FramedEngine.prototype.focus = function() {
|
||||
this.domNode.focus();
|
||||
}
|
||||
if(this.domNode.select) {
|
||||
$tw.utils.setSelectionByKeyword(this.domNode,this.widget.editFocusSelect);
|
||||
$tw.utils.setSelectionByKeyword(this.domNode,this.widget.editFocusSelectFromStart,this.widget.editFocusSelectFromEnd);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -124,7 +124,7 @@ SimpleEngine.prototype.focus = function() {
|
||||
this.domNode.focus();
|
||||
}
|
||||
if(this.domNode.select) {
|
||||
$tw.utils.setSelectionByKeyword(this.domNode,this.widget.editFocusSelect);
|
||||
$tw.utils.setSelectionByKeyword(this.domNode,this.widget.editFocusSelectFromStart,this.widget.editFocusSelectFromEnd);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -180,7 +180,8 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
||||
this.editMinHeight = this.getAttribute("minHeight",DEFAULT_MIN_TEXT_AREA_HEIGHT);
|
||||
this.editFocusPopup = this.getAttribute("focusPopup");
|
||||
this.editFocus = this.getAttribute("focus");
|
||||
this.editFocusSelect = this.getAttribute("focusSelect","yes");
|
||||
this.editFocusSelectFromStart = $tw.utils.parseNumber(this.getAttribute("focusSelectFromStart","0"));
|
||||
this.editFocusSelectFromEnd = $tw.utils.parseNumber(this.getAttribute("focusSelectFromEnd","0"));
|
||||
this.editTabIndex = this.getAttribute("tabindex");
|
||||
this.editCancelPopups = this.getAttribute("cancelPopups","") === "yes";
|
||||
this.editInputActions = this.getAttribute("inputActions");
|
||||
|
@ -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) {
|
||||
|
@ -24,7 +24,8 @@ The content of the `<$edit-text>` widget is ignored.
|
||||
|placeholder |Placeholder text to be displayed when the edit field is empty |
|
||||
|focusPopup |Title of a state tiddler for a popup that is displayed when the editing element has focus |
|
||||
|focus |Set to "yes" or "true" to automatically focus the editor after creation |
|
||||
|focusSelect |<<.from-version 5.2.26>> If `focus` attribute is enabled, determines how the text is selected: "start" places the cursor at the start of the text, "end" or "no" places the cursor at the end of the text and "yes" (the default) selects the entire text |
|
||||
|focusSelectFromStart |<<.from-version 5.2.26>> If the `focus` attribute is enabled, determines the position of the start of the selection: 0 (the default) places the start of the selection at the beginning of the text, 1 places the start of the selection after the first character etc |
|
||||
|focusSelectFromEnd |<<.from-version 5.2.26>> If the `focus` attribute is enabled, determines the position of the end of the selection: 0 (the default) places the end of the selection at the end of the text, 1 places the start of the selection before the final character etc |
|
||||
|tabindex |Sets the `tabindex` attribute of the input or textarea to the given value |
|
||||
|autocomplete |<<.from-version 5.1.23>> An optional string to provide a hint to the browser how to handle autocomplete for this input |
|
||||
|tag |Overrides the generated HTML editing element tag. For a multi-line editor use `tag=textarea`. For a single-line editor use `tag=input` |
|
||||
@ -39,7 +40,6 @@ The content of the `<$edit-text>` widget is ignored.
|
||||
|disabled|<<.from-version "5.1.23">> Optional, disables the text input if set to "yes". Defaults to "no"|
|
||||
|fileDrop|<<.from-version "5.2.0">> Optional. When set to "yes" allows dropping or pasting images into the editor to import them. Defaults to "no"|
|
||||
|
||||
|
||||
! Example
|
||||
|
||||
If you wanted to change the field //myconfig// of the tiddler //AppSettings//, you could use an EditTextWidget to edit the field, and then show the result anywhere else by using `{{AppSettings!!myconfig}}`. Note that this will create tiddler AppSettings if it doesn't already exist.
|
||||
|
Loading…
Reference in New Issue
Block a user