Skip to content

Commit

Permalink
feat: expose adding command and event from editor (refs nhn#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Midgley committed May 21, 2020
1 parent d0a1c47 commit db5e6dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
// Using Method: Customize the first button
const toolbar = editor.getUI().getToolbar();

editor.eventManager.addEventType('clickCustomButton');
editor.eventManager.listen('clickCustomButton', function() {
editor.addEventType('clickCustomButton');
editor.on('clickCustomButton', function() {
alert('Click!');
});

Expand Down
2 changes: 2 additions & 0 deletions apps/editor/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ declare namespace toastui {

public addWidget(selection: Range, node: Node, style: string, offset?: number): void;

public addEventType(type: string): void;

public afterAddedCommand(): void;

public blur(): void;
Expand Down
8 changes: 8 additions & 0 deletions apps/editor/src/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ class ToastUIEditor {
}
}

/**
* Add event type when given event not exists
* @param {string} type Event type name
*/
addEventType(type) {
this.eventManager.addEventType(type);
}

/**
* After added command.
*/
Expand Down

0 comments on commit db5e6dc

Please sign in to comment.