# HG changeset patch # User Alexandre Segura # Date 1496326508 -7200 # Node ID 4a8bbd314a460cbe73655f3be8de39f79758e436 # Parent df6780e48eb598b68e55b4e7efa9b1a200c834cd Store note JSON data. diff -r df6780e48eb5 -r 4a8bbd314a46 client/src/actions/notesActions.js --- 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 } }; } diff -r df6780e48eb5 -r 4a8bbd314a46 client/src/components/Note.js --- 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 (
- {note.text} + {note.plain}
); }; diff -r df6780e48eb5 -r 4a8bbd314a46 client/src/components/NoteInput.js --- 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); } diff -r df6780e48eb5 -r 4a8bbd314a46 client/src/components/SlateEditor.js --- 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); diff -r df6780e48eb5 -r 4a8bbd314a46 client/src/store/noteRecord.js --- 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: {} });