From 2db016756d73962ee5c219caf25cf1b69bc24ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Marti=CC=81n=20Pithod?= Date: Thu, 24 May 2018 11:59:29 -0300 Subject: [PATCH 1/2] Add condition to check if the edit image button already exists --- src/dom_components/model/ComponentImage.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/dom_components/model/ComponentImage.js b/src/dom_components/model/ComponentImage.js index e27227899..55f61aef3 100644 --- a/src/dom_components/model/ComponentImage.js +++ b/src/dom_components/model/ComponentImage.js @@ -34,12 +34,24 @@ module.exports = Component.extend( // Add Image Editor button only if the default command exists if (cmd.has(cmdName)) { + let hasButtonBool = false; var tb = this.get('toolbar'); - tb.push({ - attributes: { class: 'fa fa-pencil' }, - command: cmdName - }); - this.set('toolbar', tb); + + if ( + tb.forEach(button => { + if (button.command === 'image-editor') { + hasButtonBool = true; + } + }) + ); + + if (!hasButtonBool) { + tb.push({ + attributes: { class: 'fa fa-pencil' }, + command: cmdName + }); + this.set('toolbar', tb); + } } } }, From 978c5aa22bac5e60529c8f6e285f3eec5b00bec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Marti=CC=81n=20Pithod?= Date: Thu, 24 May 2018 16:05:32 -0300 Subject: [PATCH 2/2] Fixes --- src/dom_components/model/ComponentImage.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/dom_components/model/ComponentImage.js b/src/dom_components/model/ComponentImage.js index 55f61aef3..b4c77b4a1 100644 --- a/src/dom_components/model/ComponentImage.js +++ b/src/dom_components/model/ComponentImage.js @@ -37,13 +37,12 @@ module.exports = Component.extend( let hasButtonBool = false; var tb = this.get('toolbar'); - if ( - tb.forEach(button => { - if (button.command === 'image-editor') { - hasButtonBool = true; - } - }) - ); + for (let i = 0; i < tb.length; i++) { + if (tb[i].command === 'image-editor') { + hasButtonBool = true; + break; + } + } if (!hasButtonBool) { tb.push({