Mailspring/internal_packages/composer-signature/lib/signature-composer-extension.coffee
Drew Regitsky da15d4598c fix(signatures): Wrap signature in a nylas-n1-signature div to allow easy detection
Summary:
Changes the internal signatures plugin to wrap the signature in a
`<div class="nylas-n1-signature">` block, to make it easier to detect and handle
signatures from within other plugins.

Also:
- Fixes the QuickSchedule plugin to place the scheduling block above the signature.
- Fixes a small syntax error in Translate plugin

Test Plan: manual

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2383
2015-12-29 15:33:49 -08:00

14 lines
620 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')
if insertionPoint is -1
insertionPoint = draft.body.length
draft.body = draft.body.slice(0, insertionPoint) + '<br/><div class="nylas-n1-signature">' + signature + "</div>" + draft.body.slice(insertionPoint)
module.exports = SignatureComposerExtension