define([ 'jquery', '/common/common-util.js', '/common/diffMarked.js', '/common/hyperscript.js', '/bower_components/hyperjson/hyperjson.js', '/bower_components/nthen/index.js', '/lib/turndown.browser.umd.js' ], function ($, Util, DiffMd, h, Hyperjson, nThen, Turndown) { var module = { ext: '.html', // default exts: ['.html', '.md', '.doc'] }; module.importMd = function (md, common) { var html = DiffMd.render(md, true, false, true); var div = h('div#cp-temp'); DiffMd.apply(html, $(div), common); var body = h('body'); body.innerHTML = div.innerHTML; return body; }; var exportMediaTags = function (inner, cb) { var $clone = $(inner).clone(); nThen(function (waitFor) { $(inner).find('media-tag').each(function (i, el) { var blob = Util.find(el, ['_mediaObject','_blob', 'content']); if (!blob) { return; } Util.blobToImage(blob, waitFor(function (imgSrc) { $clone.find('media-tag[src="' + $(el).attr('src') + '"] img') .attr('src', imgSrc); $clone.find('media-tag').parent() .find('.cke_widget_drag_handler_container').remove(); })); }); }).nThen(function () { cb($clone[0]); }); }; var cleanHtml = function (inner) { return inner.innerHTML.replace(/]*class="cke_anchor"[^>]*data-cke-realelement="([^"]*)"[^>]*>/g, function(match,realElt){ //console.log("returning realElt \"" + unescape(realElt)+ "\"."); return decodeURIComponent(realElt); }); }; module.getHTML = function (inner) { return ('\n' + '\n' + '
\n ' + cleanHtml(inner) + ' \n' ); }; var exportDoc = function (inner) { var preHtml = "