var editor = document.getElementById ("editor-content");
var bold = document.createEvent('TextEvent');
bold.initTextEvent('textInput', true, true, null, "**"+"boldtext"+"**");
editor.dispatchEvent(bold);
I am currently making a markdown editor with a textarea.
When a button is pressed, the above code will run.
It runs perfectly but I want the "boldtext"to be highlighted(selected) when it is inserted into the textarea.
How would I do this? Right now the cursor is put at the end of **boldtext**
.
Like this.
**boldtext|**