How to use undo and redo function for annotations

I know hotkeys are available but I want to trigger undo and redo over a button click outside the viewer.
I have also tried trigger event for hotkeys but it doesn’t work.
Please suggest me something to use this default feature for undo and redo of annotations.

How to use this methods?

      this.viewerInstance.CoreControls.AnnotationHistoryManager.undo();

This doesn’t work. Please let me know the actual way to invoke that method.

Hi!

To get reference to the history manager you can call docViewer.getAnnotationHistoryManager(), then you should have access to the APIs above. We will update the documenation to make this a bit more clear.

WebViewer((), ele).then(instance => {
   const { docViewer } = instance;
   const historyManager = docViewer.getAnnotationHistoryManager()

    historyManager.undo();
})

I hope this helps!
Thanks,
Logan