2016-08-31 10:23:01 +08:00
|
|
|
marked = require 'marked'
|
|
|
|
Utils = require './utils'
|
|
|
|
{ComposerExtension} = require 'nylas-exports'
|
|
|
|
|
|
|
|
rawBodies = {}
|
|
|
|
|
|
|
|
class MarkdownComposerExtension extends ComposerExtension
|
|
|
|
|
2016-09-24 07:34:09 +08:00
|
|
|
@applyTransformsForSending: ({draftBodyRootNode, draft}) ->
|
|
|
|
rawBodies[draft.clientId] = draftBodyRootNode.innerHTML
|
|
|
|
draftBodyRootNode.innerHTML = marked(draftBodyRootNode.innerText)
|
2016-08-31 10:23:01 +08:00
|
|
|
|
2016-09-24 07:34:09 +08:00
|
|
|
@unapplyTransformsForSending: ({draftBodyRootNode, draft}) ->
|
|
|
|
if rawBodies[draft.clientId]
|
|
|
|
draftBodyRootNode.innerHTML = rawBodies[draft.clientId]
|
2016-08-31 10:23:01 +08:00
|
|
|
|
|
|
|
module.exports = MarkdownComposerExtension
|