wisemapping-frontend/packages/webapp/src/components/maps-page/editor/index.tsx

34 lines
983 B
TypeScript
Raw Normal View History

2022-01-25 19:10:40 +01:00
import React from 'react';
import ActionDispatcher from '../action-dispatcher';
import { ActionType } from '../action-chooser';
import WiseEditor from '@wisemapping/editor';
2022-02-05 22:53:10 +01:00
import AppI18n from '../../../classes/app-i18n';
2022-01-25 19:10:40 +01:00
export type EditorPropsType = {
mapId: number;
memoryPersistence: boolean;
readOnlyMode: boolean;
};
2022-02-05 22:53:10 +01:00
export default function Editor({ mapId, ...props }: EditorPropsType): React.ReactElement {
2022-01-25 19:10:40 +01:00
const [activeDialog, setActiveDialog] = React.useState<ActionType | null>(null);
2022-02-05 22:53:10 +01:00
// Load user locale ...
const appi18n = new AppI18n();
const userLocale = appi18n.getUserLocale();
2022-01-25 19:10:40 +01:00
return <>
2022-02-05 22:53:10 +01:00
<WiseEditor {...props} onAction={setActiveDialog} locale={userLocale.code} />
2022-01-25 19:10:40 +01:00
{
2022-02-05 22:53:10 +01:00
activeDialog &&
2022-01-25 19:10:40 +01:00
<ActionDispatcher
action={activeDialog}
onClose={() => setActiveDialog(null)}
mapsId={[mapId]}
fromEditor
/>
}
</>
}