mirror of
https://github.com/codex-team/editor.js
synced 2024-05-08 01:16:46 +02:00
2d89105670
* Add internal wrappers for tools classes * FIx lint * Change tools collections to map * Apply some more refactoring * Make tool instance private field * Add some docs * Fix eslint * Basic implementation for Block Tunes * Small fix for demo * Review changes * Fix * Add common tunes and ToolsCollection class * Fixes after review * Rename tools collections * Readonly fix * Some fixes after review * Apply suggestions from code review Co-authored-by: Peter Savchenko <specc.dev@gmail.com> * Fixes after review * Add docs and changelog * Update docs/block-tunes.md Co-authored-by: Peter Savchenko <specc.dev@gmail.com> * Apply suggestions from code review Co-authored-by: Peter Savchenko <specc.dev@gmail.com> * Update src/components/block/index.ts Co-authored-by: Murod Khaydarov <murod.haydarov@gmail.com> * [Dev] Tools utils tests (#1602) * Add tests for tools utils and coverage report * Fix eslint * Adjust test * Add more tests * Update after code review * Fix test & bump version Co-authored-by: Peter Savchenko <specc.dev@gmail.com> Co-authored-by: Murod Khaydarov <murod.haydarov@gmail.com>
67 lines
1.3 KiB
TypeScript
67 lines
1.3 KiB
TypeScript
import {API, BlockAPI, ToolConfig} from '../index';
|
|
import { BlockTuneData } from './block-tune-data';
|
|
|
|
/**
|
|
* Describes BLockTune blueprint
|
|
*/
|
|
export interface BlockTune {
|
|
/**
|
|
* Returns block tune HTMLElement
|
|
*
|
|
* @return {HTMLElement}
|
|
*/
|
|
render(): HTMLElement;
|
|
|
|
/**
|
|
* Method called on Tool render. Pass Tool content as an argument.
|
|
*
|
|
* You can wrap Tool's content with any wrapper you want to provide Tune's UI
|
|
*
|
|
* @param {HTMLElement} pluginsContent — Tool's content wrapper
|
|
*
|
|
* @return {HTMLElement}
|
|
*/
|
|
wrap?(pluginsContent: HTMLElement): HTMLElement;
|
|
|
|
/**
|
|
* Called on Tool's saving. Should return any data Tune needs to save
|
|
*
|
|
* @return {BlockTuneData}
|
|
*/
|
|
save?(): BlockTuneData;
|
|
}
|
|
|
|
/**
|
|
* Describes BlockTune class constructor function
|
|
*/
|
|
export interface BlockTuneConstructable {
|
|
|
|
/**
|
|
* Flag show Tool is Block Tune
|
|
*/
|
|
isTune: boolean;
|
|
|
|
/**
|
|
* @constructor
|
|
*
|
|
* @param config - Block Tune config
|
|
*/
|
|
new(config: {
|
|
api: API,
|
|
settings?: ToolConfig,
|
|
block: BlockAPI,
|
|
data: BlockTuneData,
|
|
}): BlockTune;
|
|
|
|
/**
|
|
* Tune`s prepare method. Can be async
|
|
* @param data
|
|
*/
|
|
prepare?(): Promise<void> | void;
|
|
|
|
/**
|
|
* Tune`s reset method to clean up anything set by prepare. Can be async
|
|
*/
|
|
reset?(): void | Promise<void>;
|
|
}
|