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

View File

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