Open zeroxx1986 opened 8 years ago
I'd like this ability as well, or even just to exposed _replaceSelection() to the outside world. My use case is that my 'Insert Image' button is a custom action that will pop up a modal box allowing the user to search and select images in a custom gallery that we have, and finally return the path of the image back to the application for rendering, which is the part I'm currently stuck at.
Did you tried like that?
pos = simplemde.codemirror.getCursor();
simplemde.codemirror.setSelection(pos, pos);
simplemde.codemirror.replaceSelection(image-url);
codemirror.replaceSelection works fine, thanks. Strangely, I'm sure I had tried this before and it wasn't working. One of those odd problems I guess!
@seamus-45 thanks~ I success
Can also use replaceRange
:
const pos = simplemde.codemirror.getCursor();
simplemde.codemirror.replaceRange("hello world", pos);
In the preview it is also possible, or there is another way to intercept the selection in the preview panel ? @seamus-45 @sn3p
Hello!
I'm currently writing a note application, and I want to be able to insert text programatically at the cursor position. I tried it with value(), but that can only insert the text at the end, and as far as I can tell, I couldn't see any proper way to get the cursor position in regards to the raw value, so I can split the raw text and insert the needed addition by myself. Why would I need it? I'm trying to handle drag&drop functionality also, and upon a file drag I'm inserting the file's path.