Skip to content

Commit

Permalink
Sets <p> margin to 0 for sent emails
Browse files Browse the repository at this point in the history
Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>
  • Loading branch information
StCyr committed Feb 3, 2020
1 parent d7c1cdf commit 8bb5bec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ export default {
bcc: this.selectBcc.map(this.recipientToRfc822).join(', '),
draftUID: uid,
subject: this.subjectVal,
body: this.editorPlainText ? htmlToText(this.bodyVal) : this.bodyVal,
body: this.editorPlainText ?
htmlToText(this.bodyVal) : '<style>.null-margin{margin:0;}</style>' + this.bodyVal,
attachments: this.attachments,
folderId: this.replyTo ? this.replyTo.folderId : undefined,
messageId: this.replyTo ? this.replyTo.messageId : undefined,
Expand Down
16 changes: 15 additions & 1 deletion src/components/TextEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
placeholder: this.placeholder,
plugins: this.html
? [EssentialsPlugin, ParagraphPlugin, BoldPlugin, ItalicPlugin, LinkPlugin, BlockQuotePlugin]
: [EssentialsPlugin, ParagraphPlugin],
: [EssentialsPlugin, ParagraphPlugin, NullMarginPlugin],
toolbar: {
items: this.html ? ['bold', 'italic', 'blockquote', 'link', 'undo', 'redo'] : ['undo', 'redo'],
},
Expand Down Expand Up @@ -115,6 +115,20 @@ export default {
onEditorReady(editor) {
const schema = editor.model.schema

// Assign 'null-margin' class to all <p> elements
editor.conversion.for('downcast').add(dispatcher => {
dispatcher.on(
'insert:paragraph',
(evt, data, conversionApi) => {
const viewWriter = conversionApi.writer
viewWriter.addClass('null-margin', conversionApi.mapper.toViewElement(data.item))
},
{
priority: 'low'
}
)
})

schema.on(
'checkChild',
(evt, args) => {
Expand Down

0 comments on commit 8bb5bec

Please sign in to comment.