Live input position API
Build adjustable Auto Text shortcuts
Maintain a browser-side shortcut dictionary, then type any shortcut followed by Space in the editor to replace it with the complete phrase.
Try it in the document
Place the caret in the editor and type the selected trigger as a complete word.
SPACE TO EXPAND
TY
+
Space
Thanks for your request.
Waiting for a shortcutType one of the registered triggers in the editor.
Available shortcuts
Select an entry to load it into the editor above, or remove shortcuts that are no longer required.
0 ENTRIES
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Application-defined phrases at the current input position
Auto Text accelerates repetitive writing such as correspondence, support replies, legal clauses, and standardized terminology. The application owns the shortcut dictionary, while TX Text Control supplies the live input position and document editing APIs used to perform the replacement.
Current caret
TXTextControl.inputPosition
Select shortcut
TXTextControl.select
Insert phrase
TXTextControl.selection.setText
Caret tracking
inputPositionChanged
How it works
The demo listens for printable characters inside the editor container. When Space completes a word, the typed value is normalized and looked up in a JavaScript Map. This makes the shortcut collection application data that can be edited, loaded from a service, or adapted to the current user.
inputPositionChanged tracks the caret and clears the buffered word after navigation or a non-contiguous position change. This prevents characters typed at unrelated document locations from being combined into one shortcut.
For a match, InputPosition.getTextPosition returns the current document position. TXTextControl.select selects the shortcut immediately before the caret, and Selection.setText replaces it with the registered phrase and a trailing space.
TXTextControl.inputPosition.getTextPosition(position => {
TXTextControl.select(position - shortcut.length, shortcut.length, () => {
TXTextControl.selection.setText(replacement + " ");
});
});