From f25d900b38f06ffb9ce2fa05d11be87f9fac744b Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Sun, 16 Apr 2017 17:54:14 +0300
Subject: [PATCH] disable isolated notes when editor in view only mode

---
 app/components/SimpleEditor/Editor.js                       | 1 +
 .../elements/isolatedNote/IsolatedNoteComponent.js          | 2 +-
 .../elements/track_change/TrackChangeComponent.js           | 1 +
 app/components/SimpleEditor/miniEditor/miniEditor.js        | 1 +
 app/components/SimpleEditor/panes/Notes/Notes.js            | 6 ++++++
 5 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/app/components/SimpleEditor/Editor.js b/app/components/SimpleEditor/Editor.js
index 87d1d91..88a783a 100644
--- a/app/components/SimpleEditor/Editor.js
+++ b/app/components/SimpleEditor/Editor.js
@@ -193,6 +193,7 @@ class Editor extends ProseEditor {
     const configurator = this.props.configurator
     const editing = this.props.disabled ? 'selection' : 'full'
     return $$(ContainerEditor, {
+      disabled: this.props.disabled,
       editing: editing,
       editorSession: this.editorSession,
       commands: configurator.getSurfaceCommandNames(),
diff --git a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteComponent.js b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteComponent.js
index b76cca0..0ad0e0f 100644
--- a/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteComponent.js
+++ b/app/components/SimpleEditor/elements/isolatedNote/IsolatedNoteComponent.js
@@ -7,7 +7,7 @@ class IsolatedNoteComponent extends BlockNodeComponent {
     el.append(
     $$(TextPropertyEditor, {
       path: [this.props.node.id, 'content'],
-      disabled: this.props.disabled,
+      disabled: this.context.editor.props.disabled,
       tagName: 'p',
       multiLine: true
     }).ref('noteContentEditor-' + this.props.node.id))
diff --git a/app/components/SimpleEditor/elements/track_change/TrackChangeComponent.js b/app/components/SimpleEditor/elements/track_change/TrackChangeComponent.js
index f68e107..1305384 100644
--- a/app/components/SimpleEditor/elements/track_change/TrackChangeComponent.js
+++ b/app/components/SimpleEditor/elements/track_change/TrackChangeComponent.js
@@ -52,6 +52,7 @@ class TrackChangeComponent extends AnnotationComponent {
     el.addClass('sc-track-change-' + status)
 
     if (viewMode === false) {
+      console.log('status', status)
       if (status === 'delete') el.addClass('sc-track-delete-hide')
       if (status === 'add') el.addClass('sc-track-add-show')
     }
diff --git a/app/components/SimpleEditor/miniEditor/miniEditor.js b/app/components/SimpleEditor/miniEditor/miniEditor.js
index b4e91a6..025b1e9 100644
--- a/app/components/SimpleEditor/miniEditor/miniEditor.js
+++ b/app/components/SimpleEditor/miniEditor/miniEditor.js
@@ -67,6 +67,7 @@ class MiniEditor extends ProseEditor {
       comments: this.props.comments,
       containerId: this.props.containerId,
       editorSession: this.editorSession,
+      disabled: this.props.disabled,
       fragment: this.props.fragment,
       spellcheck: 'native',
       trackChanges: this.props.trackChanges,
diff --git a/app/components/SimpleEditor/panes/Notes/Notes.js b/app/components/SimpleEditor/panes/Notes/Notes.js
index e1a9504..a044440 100644
--- a/app/components/SimpleEditor/panes/Notes/Notes.js
+++ b/app/components/SimpleEditor/panes/Notes/Notes.js
@@ -49,10 +49,12 @@ class Notes extends Component {
     const user = this.getUser()
     const update = this.getUpdate()
     const trackChanges = this.trackChanges()
+    const disabled = this.isInReadOnlyMode()
 
     el.append($$(MiniEditor, {
       comments: comments,
       containerId: 'mini',
+      disabled: disabled,
       editorSession: miniEditorSession,
       fragment: fragment,
       trackChanges: trackChanges,
@@ -125,6 +127,10 @@ class Notes extends Component {
     return this.context.editor.props.user
   }
 
+  isInReadOnlyMode () {
+    return this.context.editor.props.disabled
+  }
+
   getFragment () {
     return this.context.editor.props.fragment
   }
-- 
GitLab