diff --git a/apps/editor/examples/example19-customizing-toolbar-buttons.html b/apps/editor/examples/example19-customizing-toolbar-buttons.html index b19aa77746..6e5f24a705 100644 --- a/apps/editor/examples/example19-customizing-toolbar-buttons.html +++ b/apps/editor/examples/example19-customizing-toolbar-buttons.html @@ -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!'); }); diff --git a/apps/editor/index.d.ts b/apps/editor/index.d.ts index f8570cf5e3..1407d7d770 100644 --- a/apps/editor/index.d.ts +++ b/apps/editor/index.d.ts @@ -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; diff --git a/apps/editor/src/js/editor.js b/apps/editor/src/js/editor.js index 81262c7123..fc17df6c85 100644 --- a/apps/editor/src/js/editor.js +++ b/apps/editor/src/js/editor.js @@ -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. */