I have a plugin and inside my execute method I am doing the following:
var selection = new scribe.api.Selection();
var range = selection.range;
var newLine = document.createElement('p');
// Insert the new P node after the OL
range.startContainer.parentNode.parentNode.parentNode.insertBefore(newLine, range.startContainer.parentNode.parentNode.nextSibling);
// Select the new P node. I am assuming that this should set the startContaine, endContainer and all other properties of range.
range.selectNode(newLine);
selection.selection.removeAllRanges();
selection.selection.addRange(range);
I have the following list already inside the target div:
<ol><li>some content</li><li>some more content</li></ol>
I place the cursor at the end of the second LI and then call execute. I would expect the selection range start container to be the new P element I created and called selectNode on. This is not the case, instead the div element is selected.
Am I misunderstanding something or does the selection process have an issue with lists?
I would also like to mention if that if I do this without a list and just insert the new P tag in the target div, everything works as expected. The range points to the new P tag.
I have a plugin and inside my execute method I am doing the following:
I have the following list already inside the target div:
I place the cursor at the end of the second LI and then call execute. I would expect the selection range start container to be the new P element I created and called selectNode on. This is not the case, instead the div element is selected.
Am I misunderstanding something or does the selection process have an issue with lists?
I would also like to mention if that if I do this without a list and just insert the new P tag in the target div, everything works as expected. The range points to the new P tag.