How UndoRedo plugin works with Angular wrapper

Tags: #<Tag:0x00007f8b2b0fe6d8>

Hello,
I’m triying to use the UndoRedo plugin with the angular wrapper.
In addition to Undo Redo action in the context menu I want 2 buttons in a toolbar that can perform these actions.
I try to implement these action like the following way: ( like every other plugin action)

    hotSettings?: Handsontable.GridSettings = {
       ...
      undo: true,
      ...
   };
   let hotInstance = this.hotRegisterer.getInstance(this.hotTableId);
   let undoPlugin = hotInstance.getPlugin("UndoRedo");
   undoPlugin.undo();

My IDE and on compilation I get the error:
Argument of type ‘“UndoRedo”’ is not assignable to parameter of type ‘“mergeCells” | “hiddenColumns” | “autoColumnSize” | “autofill” | “autoRowSize” | “basePlugin” | “bindRowsWithHeaders” | “collapsibleColumns” | “columnSorting” | “columnSummary” | … 24 more … | “trimRows”’.ts(

Would you explain me what I’m doing wrong to have this plugin works ?

My environment :
Angular 8.2.10
@handsontable/angular:5.1.0
handsontable: 7.2.1

UndoRedo is the only plugin that cannot be called via getPlugin method.

You should call undo directly from the instance. Demo https://jsfiddle.net/fgts8wa6/

This issue has been mentioned here https://github.com/handsontable/handsontable/issues/4192

According to your answer I change my code to this for the Undo Action:

let hotInstance = this.hotRegisterer.getInstance(this.hotTableId);
hotInstance.undo();

and now when I perform a ng build I get the following error:

ERROR - error TS2339: Property ‘undo’ does not exist on type ‘Handsontable’.

Here https://jsfiddle.net/z8cobmaj/ is an Angular demo. Maybe the reference is set differently. It seem to look the same as yours but it works in the demo.

Thank you for the help.

I was not able to get it works with the provided jsfiddle.
So for having the undo redo working I try to cast hot instance to any type and it works.

let hotInstance: any = this.hotRegisterer.getInstance(this.hotTableId);
switch (toolbarAction) {
  case Constants.HOT_UNDO_ACTION:
    hotInstance.undo();
    break;
  case Constants.HOT_REDO_ACTION:
      hotInstance.redo();
  break;

Great to hear that @estelle.lemoine

I guess that we can close the topic as there are no additional questions. If you’d have any please open a new topic or send me an email to support@handsontable.com