Solution 1 :

Method 1:

Simulate the textInput Event or use execCommand
Also, you might want to look at this: Javascript textarea undo redo

Method 2:

Manually keep track of all changes made to the textareas by writing the contents to an array each time it changes. Read the pre-last item from the array when clicking the undo button and remove its last item. Maybe add some logic to undo whole words instead of single chars each time the undo button is clicked.

Problem :

I’ve created a simple tag template builder for xml, however, I didn’t know why there is no automatic undo redo feature (ctrl+z) for the added tags.

Here is a live sample: (press Run >> to activate it)

Please note: there is undo redo function for text that was typed manually, but not for added text from the buttons above. My guess is maybe because those added tags are like “built in” feature that the system doesn’t just detect.




Comment posted by ixcode

Thank you, I’ll look into that!