diff --git a/src/rich_text_editor/index.js b/src/rich_text_editor/index.js index 9982e31a2..453e0d003 100644 --- a/src/rich_text_editor/index.js +++ b/src/rich_text_editor/index.js @@ -33,7 +33,8 @@ import defaults from './config/config'; export default () => { let config = {}; let toolbar, actions, lastEl, lastElPos, globalRte; - + const eventsUp = + 'change:canvasOffset canvasScroll frame:scroll component:update'; const hideToolbar = () => { const style = toolbar.style; const size = '-1000px'; @@ -301,10 +302,8 @@ export default () => { if (em) { setTimeout(this.updatePosition.bind(this), 0); - const event = - 'change:canvasOffset canvasScroll frame:scroll component:update'; - em.off(event, this.updatePosition, this); - em.on(event, this.updatePosition, this); + em.off(eventsUp, this.updatePosition, this); + em.on(eventsUp, this.updatePosition, this); em.trigger('rte:enable', view, rte); } @@ -329,7 +328,10 @@ export default () => { } hideToolbar(); - em && em.trigger('rte:disable', view, rte); + if (em) { + em.off(eventsUp, this.updatePosition, this); + em.trigger('rte:disable', view, rte); + } } }; };