mirror of
https://github.com/codex-team/editor.js
synced 2024-05-27 19:12:56 +02:00
bcdfcdadbc
* Move all modules to ts * It works * Update README.md Co-Authored-By: gohabereg <gohabereg@users.noreply.github.com> * Interfaces * Interfaces * Move depending interfaces to external types * Update README.md * update tools * add some docs * Add some fixes * Add desctiprion for Block declaration and Core properties * Fixes due comments : * Remove Block from external types * Bump version * Update src/components/modules/tools.ts Co-Authored-By: gohabereg <gohabereg@users.noreply.github.com> * Update src/components/core.ts Co-Authored-By: gohabereg <gohabereg@users.noreply.github.com> * Rename gteBlockHTMLByIndex to getBlockByIndex * Remove unnecessary constructors * Clean up bindEvents method * Add InlineToolConstructable interface * Delete legacy notifications class * Fix zero-configuration bugs * Update inline tools and block tunes constructors
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import Module from '../../__module';
|
|
import {Events} from '../../../../types/api';
|
|
|
|
/**
|
|
* @class EventsAPI
|
|
* provides with methods working with Toolbar
|
|
*/
|
|
export default class EventsAPI extends Module {
|
|
/**
|
|
* Available methods
|
|
* @return {Events}
|
|
*/
|
|
get methods(): Events {
|
|
return {
|
|
emit: (eventName: string, data: object) => this.emit(eventName, data),
|
|
off: (eventName: string, callback: () => void) => this.off(eventName, callback),
|
|
on: (eventName: string, callback: () => void) => this.on(eventName, callback),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Subscribe on Events
|
|
* @param {String} eventName
|
|
* @param {Function} callback
|
|
*/
|
|
public on(eventName, callback): void {
|
|
this.Editor.Events.on(eventName, callback);
|
|
}
|
|
|
|
/**
|
|
* Emit event with data
|
|
* @param {String} eventName
|
|
* @param {Object} data
|
|
*/
|
|
public emit(eventName, data): void {
|
|
this.Editor.Events.emit(eventName, data);
|
|
}
|
|
|
|
/**
|
|
* Unsubscribe from Event
|
|
* @param {String} eventName
|
|
* @param {Function} callback
|
|
*/
|
|
public off(eventName, callback): void {
|
|
this.Editor.Events.off(eventName, callback);
|
|
}
|
|
|
|
}
|