Store note JSON data.
--- a/client/src/actions/notesActions.js Thu Jun 01 15:20:31 2017 +0200
+++ b/client/src/actions/notesActions.js Thu Jun 01 16:15:08 2017 +0200
@@ -2,13 +2,14 @@
import * as types from '../constants/actionTypes';
-export const addNote = (session, text) => {
+export const addNote = (session, data) => {
return {
type: types.ADD_NOTE,
note: {
id: uuidV1(),
session: session.id,
- text: text,
+ raw: data.raw,
+ plain: data.plain
}
};
}
--- a/client/src/components/Note.js Thu Jun 01 15:20:31 2017 +0200
+++ b/client/src/components/Note.js Thu Jun 01 16:15:08 2017 +0200
@@ -4,7 +4,7 @@
const Note = ({note}) => {
return (
<div id={"note-" + note.id}>
- {note.text}
+ {note.plain}
</div>
);
};
--- a/client/src/components/NoteInput.js Thu Jun 01 15:20:31 2017 +0200
+++ b/client/src/components/NoteInput.js Thu Jun 01 16:15:08 2017 +0200
@@ -17,8 +17,14 @@
}
onAddNoteClick = () => {
- const text = this.refs.editor.asPlain();
- this.props.addNote(this.props.session, text);
+ const plain = this.refs.editor.asPlain();
+ const raw = this.refs.editor.asRaw();
+
+ this.props.addNote(this.props.session, {
+ plain: plain,
+ raw: raw
+ });
+
this.refs.editor.clear();
setTimeout(() => this.refs.editor.focus(), 250);
}
--- a/client/src/components/SlateEditor.js Thu Jun 01 15:20:31 2017 +0200
+++ b/client/src/components/SlateEditor.js Thu Jun 01 16:15:08 2017 +0200
@@ -1,4 +1,4 @@
-import { Editor, Plain } from 'slate'
+import { Editor, Plain, Raw } from 'slate'
import React from 'react'
/**
@@ -106,6 +106,10 @@
return Plain.serialize(this.state.state);
}
+ asRaw = () => {
+ return Raw.serialize(this.state.state);
+ }
+
clear = () => {
const state = Plain.deserialize('');
this.onChange(state);
--- a/client/src/store/noteRecord.js Thu Jun 01 15:20:31 2017 +0200
+++ b/client/src/store/noteRecord.js Thu Jun 01 16:15:08 2017 +0200
@@ -2,6 +2,7 @@
export default Immutable.Record({
id: '',
- text: '',
- session: ''
+ session: '',
+ plain: '',
+ raw: {}
});