resolve merge conflicts with t and staging

pull/1/head
ansuz 5 years ago
commit 7153441e47

@ -8,6 +8,8 @@
position: relative; position: relative;
background-color: @colortheme_help-bg; background-color: @colortheme_help-bg;
max-height: 50%;
overflow-y: auto;
&.cp-help-hidden { &.cp-help-hidden {
display: none; display: none;
} }

@ -433,21 +433,37 @@ define([
var ext = (typeof(extension) === 'function') ? extension() : extension; var ext = (typeof(extension) === 'function') ? extension() : extension;
var suggestion = title.suggestTitle('cryptpad-document'); var suggestion = title.suggestTitle('cryptpad-document');
ext = ext || '.txt'; ext = ext || '.txt';
var types = [{ var types = [];
tag: 'a', if (Array.isArray(ext) && ext.length) {
attributes: { ext.forEach(function (_ext) {
'data-value': ext, types.push({
'href': '#' tag: 'a',
}, attributes: {
content: ext 'data-value': _ext,
}, { 'href': '#'
},
content: _ext
});
});
ext = ext[0];
} else {
types.push({
tag: 'a',
attributes: {
'data-value': ext,
'href': '#'
},
content: ext
});
}
types.push({
tag: 'a', tag: 'a',
attributes: { attributes: {
'data-value': '', 'data-value': '',
'href': '#' 'href': '#'
}, },
content: ' ' content: ' '
}]; });
var dropdownConfig = { var dropdownConfig = {
text: ext, // Button initial text text: ext, // Button initial text
caretDown: true, caretDown: true,
@ -461,14 +477,15 @@ define([
Util.fixFileName(suggestion), function (filename) Util.fixFileName(suggestion), function (filename)
{ {
if (!(typeof(filename) === 'string' && filename)) { return; } if (!(typeof(filename) === 'string' && filename)) { return; }
filename = filename + $select.getValue(); var ext = $select.getValue();
filename = filename + ext;
if (async) { if (async) {
fe(function (blob) { fe(function (blob) {
SaveAs(blob, filename); SaveAs(blob, filename);
}); }, ext);
return; return;
} }
var blob = fe(); var blob = fe(null, ext);
SaveAs(blob, filename); SaveAs(blob, filename);
}, { }, {
typeInput: $select[0] typeInput: $select[0]

@ -361,7 +361,14 @@ define([
common: Common common: Common
}; };
var $block = exp.$theme = UIElements.createDropdown(dropdownConfig); var $block = exp.$theme = UIElements.createDropdown(dropdownConfig);
$block.find('button').attr('title', Messages.themeButtonTitle); $block.find('button').attr('title', Messages.themeButtonTitle).click(function () {
var state = $block.find('.cp-dropdown-content').is(':visible');
var $c = $block.closest('.cp-toolbar-drawer-content');
$c.removeClass('cp-dropdown-visible');
if (!state) {
$c.addClass('cp-dropdown-visible');
}
});
setTheme(lastTheme, $block); setTheme(lastTheme, $block);

@ -5,15 +5,17 @@ define([
'/bower_components/nthen/index.js', '/bower_components/nthen/index.js',
], function ($, Util, Hyperjson, nThen) { ], function ($, Util, Hyperjson, nThen) {
var module = { var module = {
ext: '.html' ext: '.html', // default
exts: ['.html', '.doc']
}; };
var exportMediaTags = function (inner, cb) { var exportMediaTags = function (inner, cb) {
var $clone = $(inner).clone(); var $clone = $(inner).clone();
nThen(function (waitFor) { nThen(function (waitFor) {
$(inner).find('media-tag').each(function (i, el) { $(inner).find('media-tag').each(function (i, el) {
if (!$(el).data('blob') || !el.blob) { return; } var blob = Util.find(el, ['_mediaObject','_blob', 'content']);
Util.blobToImage(el.blob || $(el).data('blob'), waitFor(function (imgSrc) { if (!blob) { return; }
Util.blobToImage(blob, waitFor(function (imgSrc) {
$clone.find('media-tag[src="' + $(el).attr('src') + '"] img') $clone.find('media-tag[src="' + $(el).attr('src') + '"] img')
.attr('src', imgSrc); .attr('src', imgSrc);
$clone.find('media-tag').parent() $clone.find('media-tag').parent()
@ -25,18 +27,31 @@ define([
}); });
}; };
var cleanHtml = function (inner) {
return inner.innerHTML.replace(/<img[^>]*class="cke_anchor"[^>]*data-cke-realelement="([^"]*)"[^>]*>/g,
function(match,realElt){
//console.log("returning realElt \"" + unescape(realElt)+ "\".");
return decodeURIComponent(realElt);
});
};
module.getHTML = function (inner) { module.getHTML = function (inner) {
return ('<!DOCTYPE html>\n' + '<html>\n' + return ('<!DOCTYPE html>\n' + '<html>\n' +
' <head><meta charset="utf-8"></head>\n <body>' + ' <head><meta charset="utf-8"></head>\n <body>' +
inner.innerHTML.replace(/<img[^>]*class="cke_anchor"[^>]*data-cke-realelement="([^"]*)"[^>]*>/g, cleanHtml(inner) +
function(match,realElt){
//console.log("returning realElt \"" + unescape(realElt)+ "\".");
return decodeURIComponent(realElt); }) +
' </body>\n</html>' ' </body>\n</html>'
); );
}; };
module.main = function (userDoc, cb) { var exportDoc = function (inner) {
var preHtml = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'><head><meta charset='utf-8'><title>Export HTML To Doc</title></head><body>";
var postHtml = "</body></html>";
var _html = preHtml+cleanHtml(inner)+postHtml;
return _html;
};
module.main = function (userDoc, cb, ext) {
if (!ext || module.exts.indexOf(ext) === -1) { ext = module.ext; }
var inner; var inner;
if (userDoc && userDoc.tagName) { if (userDoc && userDoc.tagName) {
inner = userDoc; inner = userDoc;
@ -56,7 +71,14 @@ define([
} }
} }
exportMediaTags(inner, function (toExport) { exportMediaTags(inner, function (toExport) {
cb(new Blob([ module.getHTML(toExport) ], { type: "text/html;charset=utf-8" })); if (ext === ".doc") {
var blob = new Blob(['\ufeff', exportDoc(toExport)], {
type: 'application/msword'
});
return void cb(blob);
}
var html = module.getHTML(toExport);
cb(new Blob([ html ], { type: "text/html;charset=utf-8" }));
}); });
}; };

@ -793,8 +793,8 @@ define([
}); });
}, true); }, true);
framework.setFileExporter(Exporter.ext, function(cb) { framework.setFileExporter(Exporter.exts, function(cb, ext) {
Exporter.main(inner, cb); Exporter.main(inner, cb, ext);
}, true); }, true);
framework.setNormalizer(function(hjson) { framework.setNormalizer(function(hjson) {

Loading…
Cancel
Save