mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-07 08:37:49 +08:00
fix(composer): warn when empty body
Summary: Fixes T2276 Since the new `QuotedHTMLParser` uses full HTML parsing, when you ask it for the version of the document without the quoted nodes, it returns a full html document. Unfortunately I forgot about the 2 <br> tags we manually generate when creating a reply to a message with quoted text. This is a pretty brittle solution, but considerably easier then checking if the contents really are "blank". We could check innerText, but would have to worry about img tags and other text-invisible-but-still-valid elements. Since we control the generation of the reply in the `DraftStore`, I think this is acceptable for now Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Maniphest Tasks: T2276 Differential Revision: https://phab.nylas.com/D1730
This commit is contained in:
parent
07ef2e51a0
commit
ca95d03c5d
2 changed files with 2 additions and 2 deletions
|
@ -515,7 +515,7 @@ class ComposerView extends React.Component
|
||||||
# We insert empty br tags before quoted text.
|
# We insert empty br tags before quoted text.
|
||||||
# Our quoted text parser adds additional document elements
|
# Our quoted text parser adds additional document elements
|
||||||
onlyHasBr = (/^(<br[^>]*>)+$/gi).test(body)
|
onlyHasBr = (/^(<br[^>]*>)+$/gi).test(body)
|
||||||
onlyHasDoc = (/^<head><\/head><body><\/body>$/i).test(body)
|
onlyHasDoc = (/^<head><\/head><body><br><br><\/body>$/i).test(body)
|
||||||
bodyIsEmpty = body.length is 0 or onlyHasBr or onlyHasDoc
|
bodyIsEmpty = body.length is 0 or onlyHasBr or onlyHasDoc
|
||||||
|
|
||||||
warnings = []
|
warnings = []
|
||||||
|
|
|
@ -329,7 +329,7 @@ describe "populated composer", ->
|
||||||
useDraft.call @,
|
useDraft.call @,
|
||||||
to: [u1]
|
to: [u1]
|
||||||
subject: "Hello World"
|
subject: "Hello World"
|
||||||
body: "<head></head><body></body>"
|
body: "<head></head><body><br><br></body>"
|
||||||
makeComposer.call(@)
|
makeComposer.call(@)
|
||||||
@composer._sendDraft()
|
@composer._sendDraft()
|
||||||
expect(Actions.sendDraft).not.toHaveBeenCalled()
|
expect(Actions.sendDraft).not.toHaveBeenCalled()
|
||||||
|
|
Loading…
Reference in a new issue