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] 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); + } } } },