 
     superscript: (selection) -> selection.wrap('<sup>', '</sup>')
 
-    horizontalrule: (selection) ->
-      # todo: on a blank line don't insert line feeds
-      # todo: at the start of a line, don't insert the first line feed
-      # todo: at the end of a line don't insert the last line feed
-      selection.replace('\n- - -\n')
-
+    indent: (selection) ->
+      selection.wrapLine('> ', '', false, true)
+
+    outdent: (selection) ->
+      selection.unWrapLine('> ', '', false, true)
+
+    horizontalrule: (selection) -> selection.replace('\n- - -\n')
+
+    insertsnippet: (selection, options) ->
+      snippet = options.value
+      selection.replace(snippet.getText())
+
+    editsnippet: ->
+      return unless @snippet
+      snippet = Mercury.Snippet.find(@snippet.data('snippet'))
+      snippet.displayOptions()
+
+    removesnippet: ->
+      @snippet.remove() if @snippet
+      Mercury.trigger('hide:toolbar', {type: 'snippet', immediately: true})
 
   }
 

    @text = @element.val().substr(@start, @length)


  replace: (text, select = false) ->
    @getDetails()
    val = @element.val()
    @element.val(val.substr(0, @start) + text + val.substr(@end, val.length))
    @select(@start, @start + text.length) if select


  select: (@start, @end) ->

      $(event.target).closest('a').attr('target', '_top') if @previewing


  html: (value = null, filterSnippets = true) ->
    if value != null
      if $.type(value) == 'string'
        @textarea.val(value)
      else
        @textarea.val(value.html)
        @selection().select(value.selection.start, value.selection.end)
    else
      return @textarea.val()


  togglePreview: ->
