I need to:
My idea is to use MediumEditor.selection.getCaretOffsets(element, range), then use some way to place the caret back to the location when I need to.
There is MediumEditor.selection.moveCursor(doc, node, offset) but it only places the caret at the start of an element.
My use case is inserting an emoji
Any news on this? I have a different usecase, but this solution would help me immensely as well.
I guess you're pretty much on your own 😞 I ended up writing a solution myself.
Hmmm… Bummer. Thanks for the reply man.
For anyone following this issue still,
I had the same requirement, and I implemented this with exportSelection selection API
```.hbs
// template.hbs
```.js
// component.js
beforeInitialization() {
//...
this.set('selectionRange',mediumEditor.exportSelection()); // returns {start: *, end: *}
}
updateContent(data) {
// Get the editor content and handle inserting emoji at the cursor position here
// and set the content of medium editor with setContent
// ...
mediumEditor.setContent(data);
}
After returning data from your emoji picker, use the positions from selectionRange to replace the content with emoji data.
Hope this helps 🙌
cc: @keligijus @jordyvandomselaar
Most helpful comment
For anyone following this issue still,
I had the same requirement, and I implemented this with
exportSelectionselection API```.hbs
// template.hbs
After returning data from your emoji picker, use the positions from
selectionRangeto replace the content with emoji data.Hope this helps 🙌
cc: @keligijus @jordyvandomselaar