2021-04-04 14:10:26 +02:00
|
|
|
import BaseTool, { InternalInlineToolSettings, ToolType } from './base';
|
|
|
|
import { InlineTool as IInlineTool, InlineToolConstructable } from '../../../types';
|
2021-03-31 22:29:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* InlineTool object to work with Inline Tools constructables
|
|
|
|
*/
|
|
|
|
export default class InlineTool extends BaseTool<IInlineTool> {
|
|
|
|
/**
|
|
|
|
* Tool type — Inline
|
|
|
|
*/
|
|
|
|
public type = ToolType.Inline;
|
|
|
|
|
2021-04-04 14:10:26 +02:00
|
|
|
/**
|
|
|
|
* Tool's constructable blueprint
|
|
|
|
*/
|
|
|
|
protected constructable: InlineToolConstructable;
|
|
|
|
|
2021-03-31 22:29:41 +02:00
|
|
|
/**
|
|
|
|
* Returns title for Inline Tool if specified by user
|
|
|
|
*/
|
|
|
|
public get title(): string {
|
|
|
|
return this.constructable[InternalInlineToolSettings.Title];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs new InlineTool instance from constructable
|
|
|
|
*/
|
2021-04-04 14:10:26 +02:00
|
|
|
public create(): IInlineTool {
|
2021-03-31 22:29:41 +02:00
|
|
|
// eslint-disable-next-line new-cap
|
|
|
|
return new this.constructable({
|
2021-04-04 14:10:26 +02:00
|
|
|
api: this.api.getMethodsForTool(this),
|
2021-03-31 22:29:41 +02:00
|
|
|
config: this.settings,
|
|
|
|
}) as IInlineTool;
|
|
|
|
}
|
|
|
|
}
|