mirror of
https://github.com/codex-team/editor.js
synced 2024-05-06 16:36:47 +02:00
63eeec0f3b
Co-authored-by: George Berezhnoy <gohabereg@users.noreply.github.com> Co-authored-by: Georgy Berezhnoy <gohabereg@gmail.com> Co-authored-by: tasuku-s <tasuku@freemind.co.jp> Co-authored-by: Athul Anil Kumar <athul7744@outlook.com> Co-authored-by: Taly <vitalik7tv@yandex.ru> Co-authored-by: flaming-cl <51183663+flaming-cl@users.noreply.github.com> Co-authored-by: Nguyen Ngoc Son <sonnn.se@gmail.com> Co-authored-by: Sisir Das K <37764463+sis-dk@users.noreply.github.com> Co-authored-by: Sisir <sisir@hellosivi.com>
54 lines
1.7 KiB
TypeScript
54 lines
1.7 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 { ToolType } from '../tools';
|
|
|
|
/**
|
|
* @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,
|
|
} as APIInterfaces;
|
|
}
|
|
|
|
/**
|
|
* Returns Editor.js Core API methods for passed tool
|
|
*
|
|
* @param toolName - how user name tool. It can be used in some API logic,
|
|
* for example in i18n to provide namespaced dictionary
|
|
*
|
|
* @param toolType - 'block' for Block Tool, 'inline' for Inline Tool, 'tune' for Block Tunes
|
|
*/
|
|
public getMethodsForTool(toolName: string, toolType = ToolType.Block): APIInterfaces {
|
|
return Object.assign(
|
|
this.methods,
|
|
{
|
|
i18n: this.Editor.I18nAPI.getMethodsForTool(toolName, toolType),
|
|
}
|
|
) as APIInterfaces;
|
|
}
|
|
}
|