ContentEditable, execCommand, insertText, does not work in numbered list

We are trying to use the API document.execCommand(“insertText”, text) on a contenteditable element. There is a problem when sending a carriage return in a numbered list. The list does not increment as expected. Instead the cursor moves to the next line and tabs into the location where the text should be but does not add a number to the list. This works correctly in IE and Chrome. Anyone know a work around for this? Is this a known bug?

What about execCommand('paste'....)?

1 Like

Thanks for the response. I tried the ‘paste’ command but that did not work. The ‘paste’ command requires the text to be on the clipboard. I don’t want these changes to effect the clipboard. Is this the right forum for this problem?

Yes I think this is the right forum. But you might get more help from the stackoverflow html5/javascript community, as the people available there are in the hundreds. Here just a couple.

Try asking here - http://stackoverflow.com/questions/tagged/javascript

The MDN page - https://developer.mozilla.org/en-US/docs/Web/API/document/execCommand#Commands - did lead me to this good example though - http://codepen.io/netsi1964/full/QbLLGW/

On this demo, make sure to first click in the contentEditable area, if there is no cursor position it won’t work obviously.