 $ = React.createElement
 
 Editor = React.createClass
-  contentUpdateFromMarkdown: ->
-    editor = @refs.editor.getDOMNode()
-    @sendMarkdown(editor.value)
+  contentUpdateFromMarkdown: (markdown)->
     @setState
-      markdown: editor.value
+      markdown: markdown
     try
-      content = md2react editor.value,
+      content = md2react markdown,
         gfm: true
         breaks: true
         tables: true

          # 触っているところより前が書き換わると維持されないという…
          () =>
            editor.setSelectionRange(caretStart, caretEnd)
          @contentUpdateFromMarkdown
    @syncMarkdownFromServer()

  sendMarkdown: (markdown)->

    content: null
    markdown: null

  onChangeTextarea: ->
    editor = @refs.editor.getDOMNode()
    @sendMarkdown(editor.value)
    @contentUpdateFromMarkdown(editor.value)

  render: ->
    $ 'div', {key: 'root'}, [
      $ 'h1', {style: {textAlign: 'center', fontFamily: '"Poiret One", cursive', fontSize: '25px', height: '50px', lineHeight: '50px'}}, 'erlang editor'
