2016-08-31 10:23:01 +08:00
|
|
|
marked = require 'marked'
|
|
|
|
Utils = require './utils'
|
2017-09-27 02:42:18 +08:00
|
|
|
{ComposerExtension} = require 'mailspring-exports'
|
2016-08-31 10:23:01 +08:00
|
|
|
|
|
|
|
rawBodies = {}
|
|
|
|
|
|
|
|
class MarkdownComposerExtension extends ComposerExtension
|
|
|
|
|
2016-09-24 07:34:09 +08:00
|
|
|
@applyTransformsForSending: ({draftBodyRootNode, draft}) ->
|
2017-06-22 04:12:49 +08:00
|
|
|
rawBodies[draft.id] = draftBodyRootNode.innerHTML
|
2016-09-24 07:34:09 +08:00
|
|
|
draftBodyRootNode.innerHTML = marked(draftBodyRootNode.innerText)
|
2016-08-31 10:23:01 +08:00
|
|
|
|
2016-09-24 07:34:09 +08:00
|
|
|
@unapplyTransformsForSending: ({draftBodyRootNode, draft}) ->
|
2017-06-22 04:12:49 +08:00
|
|
|
if rawBodies[draft.id]
|
|
|
|
draftBodyRootNode.innerHTML = rawBodies[draft.id]
|
2016-08-31 10:23:01 +08:00
|
|
|
|
|
|
|
module.exports = MarkdownComposerExtension
|