mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 15:56:10 +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
be800ac89a
commit
da15d4598c
|
@ -71,7 +71,7 @@ class TranslateButton extends React.Component
|
||||||
#
|
#
|
||||||
_renderButton: =>
|
_renderButton: =>
|
||||||
<button className="btn btn-toolbar" title="Translate">
|
<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>
|
<span style={fontSize: "9px", verticalAlign: "top"}>▼</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
|
@ -131,14 +131,21 @@ module.exports =
|
||||||
# Obtain the session for the current draft.
|
# Obtain the session for the current draft.
|
||||||
DraftStore.sessionForClientId(draftClientId).then (session) =>
|
DraftStore.sessionForClientId(draftClientId).then (session) =>
|
||||||
draftHtml = session.draft().body
|
draftHtml = session.draft().body
|
||||||
|
# Remove any quoted text at the end of the message
|
||||||
text = QuotedHTMLTransformer.removeQuotedHTML(draftHtml)
|
text = QuotedHTMLTransformer.removeQuotedHTML(draftHtml)
|
||||||
|
|
||||||
# add the block
|
# Check for an N1 signature and split that off
|
||||||
text += "<br/>"+@_createBlock(events,eventData)+"<br/>"
|
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)
|
newDraftHtml = QuotedHTMLTransformer.appendQuotedHTML(text, draftHtml)
|
||||||
|
|
||||||
# update the draft
|
# Update the draft
|
||||||
session.changes.add(body: newDraftHtml)
|
session.changes.add(body: newDraftHtml)
|
||||||
session.changes.commit()
|
session.changes.commit()
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,6 @@ class SignatureComposerExtension extends ComposerExtension
|
||||||
insertionPoint = draft.body.indexOf('<blockquote')
|
insertionPoint = draft.body.indexOf('<blockquote')
|
||||||
if insertionPoint is -1
|
if insertionPoint is -1
|
||||||
insertionPoint = draft.body.length
|
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
|
module.exports = SignatureComposerExtension
|
||||||
|
|
Loading…
Reference in a new issue