- Fix (image export) Export in Chrome; fixes #282

This commit is contained in:
Brett Zamir
2018-09-13 18:23:53 +08:00
parent 0688b9af60
commit c0ea00d36b
3 changed files with 10 additions and 5 deletions

View File

@@ -2745,6 +2745,7 @@ function build (opts) {
};
svg.loadXmlDoc = function (ctx, dom) {
let res;
svg.init(ctx);
const mapXY = function (p) {
@@ -2888,7 +2889,7 @@ function build (opts) {
// render if needed
if (needUpdate) {
draw();
draw(res);
svg.Mouse.runEvents(); // run and clear our events
}
}, 1000 / svg.FRAMERATE);
@@ -2896,7 +2897,9 @@ function build (opts) {
if (svg.ImagesLoaded()) {
waitingForImages = false;
draw(resolve);
return;
}
res = resolve;
});
};

View File

@@ -4177,7 +4177,7 @@ editor.init = function () {
// 'ICO', // Todo: Find a way to preserve transparency in SVG-Edit if not working presently and do full packaging for x-icon; then switch back to position after 'PNG'
'PNG',
'JPEG', 'BMP', 'WEBP', 'PDF'
], function (imgType) { // todo: replace hard-coded msg with uiStrings.notification.
], async function (imgType) { // todo: replace hard-coded msg with uiStrings.notification.
if (!imgType) {
return;
}
@@ -4210,17 +4210,18 @@ editor.init = function () {
}
exportWindow = window.open(popURL, exportWindowName);
}
const chrome = isChrome();
if (imgType === 'PDF') {
if (!customExportPDF && !isChrome()) {
if (!customExportPDF && !chrome) {
openExportWindow();
}
svgCanvas.exportPDF(exportWindowName, isChrome() ? 'save' : undefined);
svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined);
} else {
if (!customExportImage) {
openExportWindow();
}
const quality = parseInt($('#image-slider').val(), 10) / 100;
svgCanvas.rasterExport(imgType, quality, exportWindowName);
/* const results = */ await svgCanvas.rasterExport(imgType, quality, exportWindowName);
}
}, function () {
const sel = $(this);