Mailspring/internal_packages/composer-signature/lib/signature-composer-extension.coffee
Ben Gotow 1d94fcaaf9 fix(sig): Remove selectEnd, place cursor before sig
Summary: When focusing the composer, select the end of the last text block above any signatures / quoted text (which can be visible by default in Fwd:).

Test Plan: Run tests

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2411
2016-01-05 14:31:55 -08:00

18 lines
704 B
CoffeeScript

{ComposerExtension, AccountStore} = require 'nylas-exports'
class SignatureComposerExtension extends ComposerExtension
@prepareNewDraft: ({draft}) ->
accountId = AccountStore.current().id
signature = NylasEnv.config.get("nylas.account-#{accountId}.signature")
return unless signature
insertionPoint = draft.body.indexOf('<blockquote')
signatureHTML = '<div class="nylas-n1-signature">' + signature + '</div>'
if insertionPoint is -1
insertionPoint = draft.body.length
signatureHTML = '<br/><br/>' + signatureHTML
draft.body = draft.body.slice(0, insertionPoint) + signatureHTML + draft.body.slice(insertionPoint)
module.exports = SignatureComposerExtension