Mailspring/internal_packages/composer-markdown/lib/markdown-composer-extension.coffee

18 lines
570 B
CoffeeScript
Raw Normal View History

2016-08-31 10:23:01 +08:00
marked = require 'marked'
Utils = require './utils'
{ComposerExtension} = require 'nylas-exports'
rawBodies = {}
class MarkdownComposerExtension extends ComposerExtension
@applyTransformsForSending: ({draftBodyRootNode, draft}) ->
rawBodies[draft.clientId] = draftBodyRootNode.innerHTML
draftBodyRootNode.innerHTML = marked(draftBodyRootNode.innerText)
2016-08-31 10:23:01 +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