 
     redo: -> @html(@history.redo())
 
+    insertImage: (selection, options) -> selection.replace('![add alt text](' + encodeURI(options.value.src) + ')', true)
+
+    insertLink: (selection, options) ->
+      console.log(selection, options)
+    #selection.insertNode(options.value)
+
+    insertunorderedlist: (selection) -> selection.addList('-')
+
+    insertorderedlist: (selection) -> selection.addList('1.')
+
+    style: (selection, options) -> selection.wrap("<span class=\"#{options.value}\">", '</span>')
+
     formatblock: (selection, options) ->
-      # todo: wrap the line, not the selection
-      # todo: remove any of the other block format elements before wrapping
-      selection.wrap('## ', ' ##')
-
-    # todo: things that are wrapped should not wrap empty or strings that just contain line feeds
-    # todo: if it's an empty string that we're wrapping, put the cursor inside it
-    # todo: do we unwrap things if it's already wrapped?
+      wrappers = {
+        h1: ['# ', ' #']
+        h2: ['## ', ' ##']
+        h3: ['### ', ' ###']
+        h4: ['#### ', ' ####']
+        h5: ['##### ', ' #####']
+        h6: ['###### ', ' ######']
+        pre: ['    ', '']
+        blockquote: ['> ', '']
+        p: ['\n', '\n']
+      }
+      selection.unWrapLine("#{wrapper[0]}", "#{wrapper[1]}") for wrapperName, wrapper of wrappers
+      if options.value == 'blockquote'
+        Mercury.Regions.Markupable.actions.indent.call(@, selection, options)
+        return
+      selection.wrapLine("#{wrappers[options.value][0]}", "#{wrappers[options.value][1]}")
+
     bold: (selection) -> selection.wrap('**', '**')
 
     italic: (selection) -> selection.wrap('_', '_')


    handler.call(@, @selection(), options) if handler = Mercury.Regions.Markupable.actions[action]
    @resize()


  pushHistory: (keyCode) ->

  constructor: (@element) ->
    @el = @element.get(0)
    @getDetails()


  serialize: ->
    return {start: @start, end: @end}


  getDetails: ->
