I have the following code to insert Text at current position:
editor.model.change( writer => {
editor.model.insertContent( writer.createText('[Insert]') );
});
This works fine in most case like inserting inside a paragraph or headline. Example given:
Before:
<h2>Sample</h2>
After insertion:
<h2>Samp[Insert]le</h2>
But if the text is preformatted for example with a custom font size it breaks the html element:
Before:
<p><span class="text-huge">Sample formatted text</span></p>
After insertion:
<p><span class="text-huge">Sample fo</span>[Insert]<span class="text-huge">rmatted text</span></p>
Notice, that the Element is split up and the text is inserted without applying the custom styles. The [Insert] is set between two spans...
How can I Insert a text directly without modifying html structure?