I'm using TinyMCE v4.1 for my project and it's doing the job except for one thing.
It doesn't support formatting. It's configured to only accept text and <span> elements. The toolbar has several buttons that inserts spans which represent icons for the different objects that's related to my projects purpose.
The problem is sometimes if I insert a span and click to the right of it to insert another span, the cursor goes inside the first span and it adds the second span into the first as a child when I want it to become a sibling after the first.
Here's an example of my button implementation code inside the setup parameter function:
editor.addButton('itemType1Btn', {
text: 'Item Type #1',
icon: 'itemType1BtnIco',
onclick: function () {
var promptAnswer = prompt("Destination Color?", "#000000");
editor.insertContent("<span class='item itemType_1' data-to='" + promptAnswer + "'> </span>");
}
});
When the problem happens, the output is something like this:
<span class='item itemType_1' data-to='#000000'>
<span class='item itemType_2' data-to='#000000'> </span>
</span>
When I want it to be:
<span class='item itemType_1' data-to='#000000'> </span>
<span class='item itemType_2' data-to='#000000'> </span>
What code should I put in place of the insertContent() function to place the inserted content appropriately?
Any help is appreciated!