Kumar
Kumar

Reputation: 280

How to handle 'undo' and 'redo' functions in content-editable div

I'm working on a contenteditable div and trying to create a text editor, but in this text editor I'm adding some elements like image and div. If I'm supposed to add and remove elements in editable div and then hit CtrlZ undo function is not working (not getting element back).

Please let me know is there any solution for this. Undo function is only working for text inside the contenteditable div. Thanks in advance.

Upvotes: 0

Views: 2340

Answers (1)

Anil Talla
Anil Talla

Reputation: 709

You can use document.execCommand for undo and redo the changes in the editable div's. You can refer this document for more details execCommand

Upvotes: 1

Related Questions