I'm doing a WYSYWYG HTML5 editor With SWT by setting the contentEditable
attribute of the body tag to true
.
When I'm executing some commands like document.execCommand('bold')
, it works perfectly. But when I try to undo an operation with document.execCommand('undo')
nothing happens. I don't know if I have to set any undo manager or to do something like that. Can you help me please ?
This appears to be a common problem as Google search will reveal. The following site has a good compatibility table and demo for testing.
They also have the following statement on the demo page:
Undo/Redo doesn't work in IE. The problem is that the changes in the textarea to the right are also added to the Undo/Redo stack. There will be no textarea in the final version, so it's not necessary to solve the problem.
According to this quirksmode table, undo/redo works in all major browsers, but it has this note:
Undo works in Safari, but if you do Undo/Redo too often, it crashes. Solved in 3. If you make your own changes in the editable area, Undo/Redo continues to work in Mozilla and Safari (though it ignores your custom changes), but in IE and Opera it stops working.
I don't know how SWT might affect this, but it might be better to use
document.execCommand("undo", "", null)
ExecCommand has always been very buggy, and I don't know much about SWT, but I hope this helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With