When I delete any text in the contenteditable div by mistake, I can undo it with Ctrl + z .
But after I made some change with javascript . I can not use Ctrl + z to return to the previous change.
For example, when I add a node to the selected text, such as <p> or <h1> , I could not cancel the content until the previous change. jsfiddle.net/NfGM3/ (bad coding because I'm new to window.getSelection() )
I use div instead of textarea because I want to add node to the content.
So, how can I make this reversible in the contenteditable div after a change made with js?
source share