Fix export to images

This commit is contained in:
Paulo Gustavo Veiga 2022-02-13 08:40:49 -08:00
parent b076f482f1
commit e331ba77b9
2 changed files with 28 additions and 26 deletions

View File

@ -43,10 +43,10 @@ class BinaryImageExporter extends Exporter {
throw new Error('Images can not be exporeted');
}
async exportAndEndcode(): Promise<string> {
exportAndEncode(): Promise<string> {
const svgExporter = new SVGExporter(this.svgElement);
const svgUrl = await svgExporter.exportAndEncode();
const svgUrl = svgExporter.exportAndEncode();
return svgUrl.then((value: string) => {
// Get the device pixel ratio, falling back to 1. But, I will double the resolution to look nicer.
const dpr = (window.devicePixelRatio || 1) * 2;
@ -68,12 +68,13 @@ class BinaryImageExporter extends Exporter {
.toDataURL(this.getContentType())
.replace('image/png', 'octet/stream');
URL.revokeObjectURL(svgUrl);
URL.revokeObjectURL(value);
resolve(imgDataUri);
};
});
img.src = svgUrl;
img.src = value;
return result;
});
}
}
export default BinaryImageExporter;

View File

@ -15,6 +15,7 @@ import Client from '../../../../classes/client';
import { activeInstance } from '../../../../redux/clientSlice';
import { useSelector } from 'react-redux';
import SizeType from '@wisemapping/mindplot/src/components/SizeType';
type ExportFormat = 'svg' | 'jpg' | 'png' | 'txt' | 'mm' | 'wxml' | 'xls' | 'md';
type ExportGroup = 'image' | 'document' | 'mindmap-tool';
@ -77,7 +78,7 @@ const ExportDialog = ({
const exporter = (formatType: ExportFormat): Promise<string> => {
let svgElement: Element | null = null;
let size;
let size: SizeType;
let mindmap: Mindmap;
const designer: Designer = global.designer;