define([ 'jquery', '/common/common-util.js', '/bower_components/hyperjson/hyperjson.js', '/bower_components/nthen/index.js', ], function ($, Util, Hyperjson, nThen) { var module = { ext: '.html', // default exts: ['.html', '.doc'] }; 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 = "