Fix export in mindmap list.

This commit is contained in:
Paulo Gustavo Veiga 2022-11-21 19:37:16 -08:00
parent 4253479b75
commit eb12d6cc94
2 changed files with 6 additions and 6 deletions

View File

@ -38,11 +38,11 @@ export const buildPersistenceManagerForEditor = (mode: string): PersistenceManag
return persistenceManager; return persistenceManager;
}; };
export const getMindmapFromPersistence = (mapId: string): Mindmap => { export const fetchMindmap = async (mapId: number): Promise<Mindmap> => {
let mindmap: Mindmap; let mindmap: Mindmap;
if (AppConfig.isRestClient()) { if (AppConfig.isRestClient()) {
const persistence = new LocalStorageManager(`/c/restful/maps/{id}/document/xml`, true); const persistence = new LocalStorageManager(`/c/restful/maps/{id}/document/xml`, true);
mindmap = persistence.load(String(mapId)); mindmap = await persistence.load(String(mapId));
} else { } else {
const parser = new DOMParser(); const parser = new DOMParser();
const xmlDoc = parser.parseFromString( const xmlDoc = parser.parseFromString(
@ -55,7 +55,7 @@ export const getMindmapFromPersistence = (mapId: string): Mindmap => {
); );
const serializer = XMLSerializerFactory.getSerializer('tango'); const serializer = XMLSerializerFactory.getSerializer('tango');
mindmap = serializer.loadFromDom(xmlDoc, String(mapId)); mindmap = Promise.resolve(serializer.loadFromDom(xmlDoc, String(mapId)));
} }
return mindmap; return mindmap;
}; };

View File

@ -18,7 +18,7 @@ import {
Mindmap, Mindmap,
SizeType, SizeType,
} from '@wisemapping/editor'; } from '@wisemapping/editor';
import { getMindmapFromPersistence } from '../../../editor-page/PersistenceManagerUtils'; import { fetchMindmap } from '../../../editor-page/PersistenceManagerUtils';
import Checkbox from '@mui/material/Checkbox'; import Checkbox from '@mui/material/Checkbox';
@ -87,7 +87,7 @@ const ExportDialog = ({
setZoomToFit(!zoomToFit); setZoomToFit(!zoomToFit);
}; };
const exporter = (formatType: ExportFormat): Promise<string> => { const exporter = async (formatType: ExportFormat): Promise<string> => {
let svgElement: Element | null = null; let svgElement: Element | null = null;
let size: SizeType; let size: SizeType;
let mindmap: Mindmap; let mindmap: Mindmap;
@ -103,7 +103,7 @@ const ExportDialog = ({
} }
// exporting from map list // exporting from map list
else { else {
mindmap = getMindmapFromPersistence(String(mapId)); mindmap = await fetchMindmap(mapId);
} }
let exporter: Exporter; let exporter: Exporter;