     atom.config.set("react.decreaseIndentForNextLinePattern", decreaseIndentForNextLinePattern)
 
     # Bind events
-    atom.workspaceView.command 'react:reformat-JSX', @onReformat
-    atom.workspaceView.command 'react:HTML-to-JSX', @onHTMLToJSX
+    atom.commands.add 'atom-workspace', 'react:reformat-JSX', @onReformat
+    atom.commands.add 'atom-workspace', 'react:HTML-to-JSX', @onHTMLToJSX
 
-    # Patch edtiors language mode to get proper indention
-    @processEditor(editor) for editor in atom.workspace.getTextEditors()
-
-    @subscribe atom.workspace.onDidAddTextEditor (event) =>
-      editor = event.textEditor
-      @processEditor(editor)
-
+    atom.workspace.observeTextEditors @processEditor.bind(this)
 
 module.exports = new AtomReact

path   = require 'path'
{Subscriber} = require 'emissary'

# use same docblock parser as jsxtransformer does
isJSX = (text) ->
  docblock = require 'jstransform/src/docblock'
  doc = docblock.parse text;
  for b in doc
    return true if b[0] == 'jsx'
  false

class AtomReact
  Subscriber.includeInto(this)

            jsxformat.setOptions({});
            jsxOutput = jsxformat.format(jsxOutput)

          selection.insertText(jsxOutput, autoIndent: true);

  onReformat: ->
    jsxformat = require 'jsxformat'
    _ = require 'lodash'

    editor = atom.workspace.getActiveEditor()

    return if not editor?

    selections = editor.getSelections()
    editor.transact =>
      for selection in selections
