     # Get the file picker component (method used to pass it to the editor)
     getPicker: ->
         return @refs.attachments
-
 
 # set source of attached images
 cleanHTML = (html) ->

                , 0
                @setState focus: ''

    componentWillUnmount: ->
        # delete draft
        doDelete = =>
            window.setTimeout =>
                LayoutActionCreator.hideModal()
                messageID = @state.id
                MessageActionCreator.delete {messageID, silent, isDraft: true, inReplyTo: @props.inReplyTo}
            , 5

        # save draft one last time
        doSave = =>
            if @state.originalConversationID?
                # save one last time the draft, adding the conversationID
                message =
                    id            : @state.id
                    accountID     : @state.accountID
                    mailboxIDs    : @state.mailboxIDs
                    from          : @state.from
                    to            : @state.to
                    cc            : @state.cc
                    bcc           : @state.bcc
                    subject       : @state.subject
                    isDraft       : true
                    attachments   : @state.attachments
                    inReplyTo     : @state.inReplyTo
                    references    : @state.references
                    text          : @state.text
                    html          : @state.html
                    conversationID: @state.originalConversationID
                MessageActionCreator.send message, (error, message) ->
                    if error? or not message?
                        msg = "#{t "message action draft ko"} #{error}"
                        LayoutActionCreator.alertError msg
                    else
                        msg = "#{t "message action draft ok"}"
                        LayoutActionCreator.notify msg, autoclose: true
                        if message.conversationID?
                            # reload conversation to update its length
                            cid = message.conversationID
                            MessageActionCreator.fetchConversation cid
            else


        # If message has not been sent, ask if we should keep it or not
        #  - if yes, and the draft belongs to a conversation, add the
        #    conversationID and save the draft
        #  - if no, delete the draft
        if not @state.isDeleted and @state.isDraft and @state.id?

            if @state.composeInHTML
                newContent = MessageUtils.cleanReplyText(@state.html).replace /\s/gim, ''
                oldContent = MessageUtils.cleanReplyText(@state.initHtml).replace /\s/gim, ''
                updated = newContent isnt oldContent
            else
                updated = @state.text isnt @state.initText

            # if draft has not been updated, delete without asking confirmation
            silent = @state.isNew and not updated
            if silent
                doDelete()
            else
                # we need a timeout because of React's components life cycle
                setTimeout ->
                    # display a modal asking if we should keep or delete the draft
                    modal =
                        title       : t 'app confirm delete'
                        subtitle    : t 'compose confirm keep draft'
                        closeModal  : ->
                            doSave()
                            LayoutActionCreator.hideModal()
                        closeLabel  : t 'compose confirm draft keep'
                        actionLabel : t 'compose confirm draft delete'
                        action      : doDelete
                    LayoutActionCreator.displayModal modal
                , 0


    getInitialState: ->

        # edition of an existing draft
        if message = @props.message
            state =
                composeInHTML: @props.settings.get 'composeInHTML'
                isNew: false
            if (not message.get('html')?) and message.get('text')
                state.composeInHTML = false


            'subject': ['subject']
        getGroupedError error, @state

    sendActionMessage: ->
        return if @props.isSaving
        if (validate = @validateMessage())
            console.log 'ERROR', validate
            LayoutActionCreator.alertError t 'compose error no ' + validate[1]
            return

        message = _.clone @state

        @props.isSaving = true
        MessageActionCreator.send message, (error, message) =>
