mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
18d294c42f
Summary: We originally didn't do this because creating a DOM tree was loading images. Using range.createContextualFragment seems to do it without the tree ever being attached. Accompanying changes to src/pro are here: https://phab.nylas.com/D3300 https://github.com/nylas/edgehill/compare/bengotow/draft-dom-transformations?expand=1 Also rename applyTransformsToDraft => applyTransformsForSending. Needed a new name because the function signature has changed. AFAIK there are no open source plugins using the old functions. Test Plan: All specs updated Reviewers: evan, juan Reviewed By: evan, juan Differential Revision: https://phab.nylas.com/D3299
17 lines
570 B
CoffeeScript
17 lines
570 B
CoffeeScript
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)
|
|
|
|
@unapplyTransformsForSending: ({draftBodyRootNode, draft}) ->
|
|
if rawBodies[draft.clientId]
|
|
draftBodyRootNode.innerHTML = rawBodies[draft.clientId]
|
|
|
|
module.exports = MarkdownComposerExtension
|