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>
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
/**
|
|
* @module API
|
|
* @copyright <CodeX> 2018
|
|
*
|
|
* Each block has an Editor API instance to use provided public methods
|
|
* if you cant to read more about how API works, please see docs
|
|
*/
|
|
import Module from '../../__module';
|
|
import { API as APIInterfaces } from '../../../../types';
|
|
import { ToolClass } from '../../tools/collection';
|
|
|
|
/**
|
|
* @class API
|
|
*/
|
|
export default class API extends Module {
|
|
/**
|
|
* Editor.js Core API modules
|
|
*/
|
|
public get methods(): APIInterfaces {
|
|
return {
|
|
blocks: this.Editor.BlocksAPI.methods,
|
|
caret: this.Editor.CaretAPI.methods,
|
|
events: this.Editor.EventsAPI.methods,
|
|
listeners: this.Editor.ListenersAPI.methods,
|
|
notifier: this.Editor.NotifierAPI.methods,
|
|
sanitizer: this.Editor.SanitizerAPI.methods,
|
|
saver: this.Editor.SaverAPI.methods,
|
|
selection: this.Editor.SelectionAPI.methods,
|
|
styles: this.Editor.StylesAPI.classes,
|
|
toolbar: this.Editor.ToolbarAPI.methods,
|
|
inlineToolbar: this.Editor.InlineToolbarAPI.methods,
|
|
tooltip: this.Editor.TooltipAPI.methods,
|
|
i18n: this.Editor.I18nAPI.methods,
|
|
readOnly: this.Editor.ReadOnlyAPI.methods,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Returns Editor.js Core API methods for passed tool
|
|
*
|
|
* @param tool - tool object
|
|
*/
|
|
public getMethodsForTool(tool: ToolClass): APIInterfaces {
|
|
return Object.assign(
|
|
this.methods,
|
|
{
|
|
i18n: this.Editor.I18nAPI.getMethodsForTool(tool),
|
|
}
|
|
) as APIInterfaces;
|
|
}
|
|
}
|