1

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)

https://www.w3schools.com/code/tryit.asp?filename=GCGLRN2F8PWD

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.

IMAGE :

image

Citizen Patrol
  • 260
  • 3
  • 13
ixcode
  • 611
  • 8
  • 17

1 Answers1

0

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.

Felix Bernhard
  • 396
  • 6
  • 24