From 7394bb42b8f4a7c2f0b453cd8e8c5dd9b2690bf2 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Wed, 11 Oct 2017 02:17:00 +0200 Subject: [PATCH] Remove focus from the RTE module --- src/dom_components/view/ComponentTextView.js | 1 - src/rich_text_editor/index.js | 31 +++++--------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/dom_components/view/ComponentTextView.js b/src/dom_components/view/ComponentTextView.js index 6239ef75b..d48d7192a 100644 --- a/src/dom_components/view/ComponentTextView.js +++ b/src/dom_components/view/ComponentTextView.js @@ -29,7 +29,6 @@ module.exports = ComponentView.extend({ if (rte && editable) { try { this.activeRte = rte.enable(this, this.activeRte); - rte.focus(this, this.activeRte); } catch (err) { console.error(err); } diff --git a/src/rich_text_editor/index.js b/src/rich_text_editor/index.js index e14a766c6..479c71975 100644 --- a/src/rich_text_editor/index.js +++ b/src/rich_text_editor/index.js @@ -157,7 +157,7 @@ module.exports = () => { /** * Enable rich text editor on the element - * @param {View} view + * @param {View} view Component view * @param {Object} rte The instance of already defined RTE * @private * */ @@ -166,17 +166,17 @@ module.exports = () => { const em = config.em; const el = view.getChildrenContainer(); const customRte = this.customRte; + const actionbarContainer = toolbar; - rte = customRte ? customRte.enable(el, rte) : new RichTextEditor({el}); toolbar.style.display = ''; + rte = customRte ? customRte.enable(el, rte) : + new RichTextEditor({el, actionbarContainer}); if (em) { setTimeout(this.udpatePosition.bind(this), 0); - em.off('change:canvasOffset', this.udpatePosition, this); - em.on('change:canvasOffset', this.udpatePosition, this); - // Update position on scrolling - em.off('canvasScroll', this.udpatePosition, this); - em.on('canvasScroll', this.udpatePosition, this); + const event = 'change:canvasOffset canvasScroll'; + em.off(event, this.udpatePosition, this); + em.on(event, this.udpatePosition, this); } return rte; @@ -201,23 +201,6 @@ module.exports = () => { toolbar.style.display = 'none'; }, - /** - * Unbind rich text editor from the element - * @param {View} view - * @param {Object} rte The instance of already defined RTE - * @private - * */ - focus(view, rte) { - var customRte = this.customRte; - var el = view.getChildrenContainer(); - if (customRte) { - if(customRte.focus) - customRte.focus(el, rte); - } else { - this.attach(view); - } - }, - /** * Return the toolbar element * @return {HTMLElement}