editor.js/types/tools/inline-tool.d.ts
George Berezhnoy 4c0d806a12
[Refactor] ESLint fixed (#1100)
Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2020-04-18 21:55:19 +03:00

55 lines
1.3 KiB
TypeScript

import {BaseTool, BaseToolConstructable} from './tool';
import {API, ToolConfig} from "../index";
/**
* Base structure for the Inline Toolbar Tool
*/
export interface InlineTool extends BaseTool {
/**
* Shortcut for Tool
* @type {string}
*/
shortcut?: string;
/**
* Method that accepts selected range and wrap it somehow
* @param {Range} range - selection's range
*/
surround(range: Range): void;
/**
* Get SelectionUtils and detect if Tool was applied
* For example, after that Tool can highlight button or show some details
* @param {Selection} selection - current Selection
*/
checkState(selection: Selection): boolean;
/**
* Make additional element with actions
* For example, input for the 'link' tool or textarea for the 'comment' tool
*/
renderActions?(): HTMLElement;
/**
* Function called with Inline Toolbar closing
*/
clear?(): void;
}
/**
* Describe constructor parameters
*/
export interface InlineToolConstructorOptions {
api: API;
config?: ToolConfig;
}
export interface InlineToolConstructable extends BaseToolConstructable {
/**
* Constructor
*
* @param {InlineToolConstructorOptions} config - constructor parameters
*/
new(config: InlineToolConstructorOptions): BaseTool;
}