- 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

@@ -8,6 +8,7 @@
PDF as export (#273 @cuixiping); fixes #124 and #254 PDF as export (#273 @cuixiping); fixes #124 and #254
- Fix (image import): Put src after onload to avoid missing event; - Fix (image import): Put src after onload to avoid missing event;
check other width/height properties in case offset is 0; fixes #278 check other width/height properties in case offset is 0; fixes #278
- Fix (image export) Export in Chrome; fixes #282
- npm: Update devDeps - npm: Update devDeps
- npm: Point to official sinon-test package now that ES6 Modules - npm: Point to official sinon-test package now that ES6 Modules
support landed support landed

View File

@@ -2745,6 +2745,7 @@ function build (opts) {
}; };
svg.loadXmlDoc = function (ctx, dom) { svg.loadXmlDoc = function (ctx, dom) {
let res;
svg.init(ctx); svg.init(ctx);
const mapXY = function (p) { const mapXY = function (p) {
@@ -2888,7 +2889,7 @@ function build (opts) {
// render if needed // render if needed
if (needUpdate) { if (needUpdate) {
draw(); draw(res);
svg.Mouse.runEvents(); // run and clear our events svg.Mouse.runEvents(); // run and clear our events
} }
}, 1000 / svg.FRAMERATE); }, 1000 / svg.FRAMERATE);
@@ -2896,7 +2897,9 @@ function build (opts) {
if (svg.ImagesLoaded()) { if (svg.ImagesLoaded()) {
waitingForImages = false; waitingForImages = false;
draw(resolve); 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' // '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', 'PNG',
'JPEG', 'BMP', 'WEBP', 'PDF' '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) { if (!imgType) {
return; return;
} }
@@ -4210,17 +4210,18 @@ editor.init = function () {
} }
exportWindow = window.open(popURL, exportWindowName); exportWindow = window.open(popURL, exportWindowName);
} }
const chrome = isChrome();
if (imgType === 'PDF') { if (imgType === 'PDF') {
if (!customExportPDF && !isChrome()) { if (!customExportPDF && !chrome) {
openExportWindow(); openExportWindow();
} }
svgCanvas.exportPDF(exportWindowName, isChrome() ? 'save' : undefined); svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined);
} else { } else {
if (!customExportImage) { if (!customExportImage) {
openExportWindow(); openExportWindow();
} }
const quality = parseInt($('#image-slider').val(), 10) / 100; const quality = parseInt($('#image-slider').val(), 10) / 100;
svgCanvas.rasterExport(imgType, quality, exportWindowName); /* const results = */ await svgCanvas.rasterExport(imgType, quality, exportWindowName);
} }
}, function () { }, function () {
const sel = $(this); const sel = $(this);