client/src/components/SlateEditor.js
changeset 79 772b73e31069
parent 74 043477fd5c5c
child 80 b3a02ea6d097
--- a/client/src/components/SlateEditor.js	Thu Jun 22 12:37:53 2017 +0200
+++ b/client/src/components/SlateEditor.js	Fri Jun 23 10:16:49 2017 +0200
@@ -77,7 +77,7 @@
     plugins.push(annotationPlugin);
 
     this.state = {
-      state: Plain.deserialize(''),
+      state: props.note ? Raw.deserialize(props.note.raw) : Plain.deserialize(''),
       startedAt: null,
       finishedAt: null,
       currentSelectionText: '',
@@ -420,18 +420,31 @@
 
         {this.renderBlockButton('numbered-list', 'format_list_numbered')}
         {this.renderBlockButton('bulleted-list', 'format_list_bulleted')}
-        <div>
-          <div className="checkbox">
-            <label>
-              <input type="checkbox" checked={this.props.isChecked} onChange={this.onCheckboxChange} /> <kbd>Enter</kbd> = add note
-            </label>
-          </div>
-          <Button bsStyle="primary" disabled={this.props.isButtonDisabled} onClick={this.onButtonClick}>Add note</Button>
-        </div>
+
+        {this.renderToolbarButtons()}
       </div>
     )
   }
 
+  renderToolbarButtons = () => {
+    if (!this.props.withButtons) {
+      return (
+        <div />
+      )
+    }
+
+    return (
+      <div>
+        <div className="checkbox">
+          <label>
+            <input type="checkbox" checked={this.props.isChecked} onChange={this.onCheckboxChange} /> <kbd>Enter</kbd> = add note
+          </label>
+        </div>
+        <Button bsStyle="primary" disabled={this.props.isButtonDisabled} onClick={this.onButtonClick}>Add note</Button>
+      </div>
+    );
+  }
+
   /**
    * Render a mark-toggling toolbar button.
    *