A Vue 3 component made with Composition API. It is a contenteditable span that does a fair share of manipulation in javascript which allows it to have a custom shaped caret using pseudo-elements.
The custom caret comes with full functionality including:
- Moving with left and right arrow keys --moveIt()
- Focusing the caret on the character that was clicked --select()
- Focusing the caret on the last character when the background div 'wrapper' is clicked --reset()
- Caret follows the amount of characters typed (when backspaced, caret will update accordingly)
- Caret stays in the correct place when adding text after moving the caret using arrow keys
- When a text is selected, caret focuses to the last character of the selection
- When a selected text is deleted, caret focuses to the first character before the selected text --select()