simpleMDE: Add functionality to insert text programatically at cursor position

931 Views Asked by At

I am using simplemde-markdown-editor library and I want to be able to insert text programmatically at the cursor position.

1

There are 1 best solutions below

0
Mahdi Bashirpour On BEST ANSWER
var simplemde = new SimpleMDE();

After Create instance of simpleMDE you can do this:

var pos = simplemde.codemirror.getCursor();
simplemde.codemirror.setSelection(pos, pos);
simplemde.codemirror.replaceSelection("YOUR_TEXT");