                 else
                     s = "\\url{#{url}}"
 
-            cm = @cm()
             selections = cm.listSelections()
             selections.reverse()
             for sel in selections

        @source_editor?.focus()


    insert_link: () =>
        dialog = templates.find(".salvus-html-editor-link-dialog").clone()
        dialog.modal('show')
        dialog.find(".btn-close").off('click').click () ->

                if title.length > 0
                    title = " title='#{title}'"
                s = "<img src='#{url.val()}'#{width}#{height}#{title}>"
            selections = cm.listSelections()
            selections.reverse()
            for sel in selections
