client/src/components/SlateEditor.js
changeset 74 043477fd5c5c
parent 72 7634b424f426
child 79 772b73e31069
equal deleted inserted replaced
73:7e8cdc74d86f 74:043477fd5c5c
     1 import { Editor, Plain, Raw } from 'slate'
     1 import { Editor, Plain, Raw } from 'slate'
     2 import React from 'react'
     2 import React from 'react'
     3 import Portal from 'react-portal'
     3 import Portal from 'react-portal'
     4 import { Button } from 'react-bootstrap'
     4 import { Button } from 'react-bootstrap'
     5 import moment from 'moment'
       
     6 import Immutable from 'immutable'
     5 import Immutable from 'immutable'
     7 import HtmlSerializer from '../HtmlSerializer'
     6 import HtmlSerializer from '../HtmlSerializer'
     8 import AnnotationPlugin from '../AnnotationPlugin'
     7 import AnnotationPlugin from '../AnnotationPlugin'
     9 import CategoriesTooltip from './CategoriesTooltip'
     8 import CategoriesTooltip from './CategoriesTooltip'
       
     9 import { now } from '../utils';
    10 
    10 
    11 const plugins = [];
    11 const plugins = [];
    12 
    12 
    13 /**
    13 /**
    14  * Define the default node type.
    14  * Define the default node type.
   141       Object.assign(newState, {
   141       Object.assign(newState, {
   142         startedAt: null,
   142         startedAt: null,
   143         finishedAt: null
   143         finishedAt: null
   144       });
   144       });
   145     } else {
   145     } else {
   146       Object.assign(newState, { finishedAt: moment().format('H:mm:ss') });
   146       Object.assign(newState, { finishedAt: now() });
   147     }
   147     }
   148 
   148 
   149     // Store start time once when the first character is typed
   149     // Store start time once when the first character is typed
   150     if (!isEmpty && this.state.startedAt === null) {
   150     if (!isEmpty && this.state.startedAt === null) {
   151       Object.assign(newState, { startedAt: moment().format('H:mm:ss') });
   151       Object.assign(newState, { startedAt: now() });
   152     }
   152     }
   153 
   153 
   154     this.setState(newState)
   154     this.setState(newState)
   155 
   155 
   156     if (typeof this.props.onChange === 'function') {
   156     if (typeof this.props.onChange === 'function') {