So this is how I did.
Not exactly extending Handsontable, but pretty much the same end result.
export class BaseTable {
public _hot: Handsontable; // Handsontable features publicly accessible here
constructor(element: HTMLElement, options: GridSettings) {
const o = { ...this._baseGridSettings, ...options };
this._hot = new Handsontable(element, o);
}
// common features for all tables
public findReplace = (find: string, replace: string) => {
// ...
};
// common settings used by most tables
private _baseTableSettings: GridSettings = {
undo: false,
autoColumnSize: true,
autoRowSize: false,
columns: [],
// ...
};
}
export class BlueTable extends BaseTable {
constructor(element: HTMLElement, options: GridSettings) {
super(element, options);
this._hot.updateSettings(this._blueTableSettings);
}
public featureBlue = () => {
this._hot.countRows(); // access HoT
// ...
};
// settings used by blueTable only
private _blueTableSettings: GridSettings = {
// ...
};
}
export class RedTable extends BaseTable {
constructor(element: HTMLElement, options: GridSettings) {
super(element, options);
this._hot.updateSettings(this._redTableSettings);
}
public featureRed = () => {
// ...
};
// settings used by redTable only
private _redTableSettings: GridSettings = {
// ...
};
}
Now it should be easy to test my custom features and the logic is encapsulated nicely,
This is used in a React application and I find it is a nice approach that works well.