From 13dde0b3e091d721c260529444e9f01e27bf7d71 Mon Sep 17 00:00:00 2001
From: yannis <yannisbarlas@gmail.com>
Date: Fri, 28 Apr 2017 12:27:15 +0300
Subject: [PATCH] use existing surface function to disable tools when note is
 selected

---
 app/components/SimpleEditor/ContainerEditor.js        |  2 +-
 .../SimpleEditor/elements/note/NoteComponent.js       | 11 +++--------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/app/components/SimpleEditor/ContainerEditor.js b/app/components/SimpleEditor/ContainerEditor.js
index 4afe7f3..fdb7477 100644
--- a/app/components/SimpleEditor/ContainerEditor.js
+++ b/app/components/SimpleEditor/ContainerEditor.js
@@ -216,7 +216,7 @@ class ContainerEditor extends SubstanceContainerEditor {
     const commandStates = this.getCommandStates()
 
     each(keys(commandStates), key => {
-      const allowed = ['comment', 'note', 'save', 'undo', 'redo', 'track-change-toggle-view']
+      const allowed = ['comment', 'save', 'undo', 'redo', 'track-change-toggle-view']
       if (!includes(allowed, key)) commandStates[key].disabled = true
     })
   }
diff --git a/app/components/SimpleEditor/elements/note/NoteComponent.js b/app/components/SimpleEditor/elements/note/NoteComponent.js
index b295ffa..fa88346 100644
--- a/app/components/SimpleEditor/elements/note/NoteComponent.js
+++ b/app/components/SimpleEditor/elements/note/NoteComponent.js
@@ -42,14 +42,9 @@ class NoteComponent extends Component {
 
   // TODO -- review
   disableTools () {
-    const commandStates = this.getCommandStates()
-
-    // TODO -- this uses the same code as the fn in container editor
-    // use the fn from there
-    each(keys(commandStates), (key) => {
-      const allowed = ['comment', 'redo', 'save', 'switch-text-type', 'undo']
-      if (!includes(allowed, key)) commandStates[key].disabled = true
-    })
+    const surface = this.getSurface()
+    if (!surface) return
+    surface.disableToolbar()
 
     // TODO -- do we need the rerender here??
     this.rerender()
-- 
GitLab