mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 05:06:53 +08:00
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
This commit is contained in:
parent
2e1056f49e
commit
4528734a33
3 changed files with 12 additions and 5 deletions
|
@ -71,7 +71,7 @@ class TranslateButton extends React.Component
|
|||
#
|
||||
_renderButton: =>
|
||||
<button className="btn btn-toolbar" title="Translate">
|
||||
<RetinaImg mode={RetinaImg.Mode.ContentIsMask} url="nylas://N1-Composer-Translate/assets/translate-icon@2x.png" style={}/>
|
||||
<RetinaImg mode={RetinaImg.Mode.ContentIsMask} url="nylas://N1-Composer-Translate/assets/translate-icon@2x.png" />
|
||||
<span style={fontSize: "9px", verticalAlign: "top"}>▼</span>
|
||||
</button>
|
||||
|
||||
|
|
|
@ -131,14 +131,21 @@ module.exports =
|
|||
# Obtain the session for the current draft.
|
||||
DraftStore.sessionForClientId(draftClientId).then (session) =>
|
||||
draftHtml = session.draft().body
|
||||
# Remove any quoted text at the end of the message
|
||||
text = QuotedHTMLTransformer.removeQuotedHTML(draftHtml)
|
||||
|
||||
# add the block
|
||||
text += "<br/>"+@_createBlock(events,eventData)+"<br/>"
|
||||
# Check for an N1 signature and split that off
|
||||
sigIndex = text.indexOf('<div class="nylas-n1-signature">')
|
||||
beforeSig = if sigIndex>-1 then text.slice(0,sigIndex) else text
|
||||
afterSig = text.slice(beforeSig.length)
|
||||
|
||||
# Add the block and add back the signature if present
|
||||
text = beforeSig+"<br/>"+@_createBlock(events,eventData)+"<br/>"+afterSig
|
||||
|
||||
# Add back any quoted text
|
||||
newDraftHtml = QuotedHTMLTransformer.appendQuotedHTML(text, draftHtml)
|
||||
|
||||
# update the draft
|
||||
# Update the draft
|
||||
session.changes.add(body: newDraftHtml)
|
||||
session.changes.commit()
|
||||
|
||||
|
|
|
@ -9,6 +9,6 @@ class SignatureComposerExtension extends ComposerExtension
|
|||
insertionPoint = draft.body.indexOf('<blockquote')
|
||||
if insertionPoint is -1
|
||||
insertionPoint = draft.body.length
|
||||
draft.body = draft.body.substr(0, insertionPoint-1) + "<br/>" + signature + draft.body.substr(insertionPoint)
|
||||
draft.body = draft.body.slice(0, insertionPoint) + '<br/><div class="nylas-n1-signature">' + signature + "</div>" + draft.body.slice(insertionPoint)
|
||||
|
||||
module.exports = SignatureComposerExtension
|
||||
|
|
Loading…
Reference in a new issue