mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-14 12:08:27 +08:00
21 lines
582 B
CoffeeScript
21 lines
582 B
CoffeeScript
marked = require 'marked'
|
|
Utils = require './utils'
|
|
{ComposerExtension} = require 'nylas-exports'
|
|
|
|
|
|
rawBodies = {}
|
|
|
|
class MarkdownComposerExtension extends ComposerExtension
|
|
|
|
@applyTransformsToDraft: ({draft}) ->
|
|
nextDraft = draft.clone()
|
|
rawBodies[draft.clientId] = nextDraft.body
|
|
nextDraft.body = marked(Utils.getTextFromHtml(draft.body))
|
|
return nextDraft
|
|
|
|
@unapplyTransformsToDraft: ({draft}) ->
|
|
nextDraft = draft.clone()
|
|
nextDraft.body = rawBodies[nextDraft.clientId] ? nextDraft.body
|
|
return nextDraft
|
|
|
|
module.exports = MarkdownComposerExtension
|