To add my merge field text at the current selection, I use this code:
editor.model.change(writer => {
var position = editor.model.document.selection.getFirstPosition();
// trying to connect with the last node
position.stickiness = 'toPrevious';
writer.insertText(text_to_insert, position);
});
Unfortunately, this method doesn't preserve the styling of the previous node and defaults to the default styling. I checked the CKEditor documentation and tried adjusting the stickiness property of the position object, but it didn't make a difference.
https://i.sstatic.net/gE5z5.png
I'm trying to figure out how to insert text at the current position while maintaining the styling of the prior nodes. Any advice or suggestions are greatly appreciated!