@@ -136,7 +159,8 @@ const ImageExportModal = ({
value={projectName}
style={{ width: "30ch" }}
disabled={
- typeof appProps.name !== "undefined" || appState.viewModeEnabled
+ typeof appProps.name !== "undefined" ||
+ appStateSnapshot.viewModeEnabled
}
onChange={(event) => {
setProjectName(event.target.value);
@@ -152,16 +176,16 @@ const ImageExportModal = ({
{t("imageExportDialog.header")}
- {someElementIsSelected && (
+ {hasSelection && (
{
- setExportSelected(checked);
+ setExportSelectionOnly(checked);
}}
/>
@@ -243,7 +267,9 @@ const ImageExportModal = ({
className="ImageExportModal__settings__buttons__button"
label={t("imageExportDialog.title.exportToPng")}
onClick={() =>
- onExportImage(EXPORT_IMAGE_TYPES.png, exportedElements)
+ onExportImage(EXPORT_IMAGE_TYPES.png, exportedElements, {
+ exportingFrame,
+ })
}
startIcon={downloadIcon}
>
@@ -253,7 +279,9 @@ const ImageExportModal = ({
className="ImageExportModal__settings__buttons__button"
label={t("imageExportDialog.title.exportToSvg")}
onClick={() =>
- onExportImage(EXPORT_IMAGE_TYPES.svg, exportedElements)
+ onExportImage(EXPORT_IMAGE_TYPES.svg, exportedElements, {
+ exportingFrame,
+ })
}
startIcon={downloadIcon}
>
@@ -264,7 +292,9 @@ const ImageExportModal = ({
className="ImageExportModal__settings__buttons__button"
label={t("imageExportDialog.title.copyPngToClipboard")}
onClick={() =>
- onExportImage(EXPORT_IMAGE_TYPES.clipboard, exportedElements)
+ onExportImage(EXPORT_IMAGE_TYPES.clipboard, exportedElements, {
+ exportingFrame,
+ })
}
startIcon={copyIcon}
>
@@ -325,15 +355,20 @@ export const ImageExportDialog = ({
onExportImage: AppClassProperties["onExportImage"];
onCloseRequest: () => void;
}) => {
- if (appState.openDialog !== "imageExport") {
- return null;
- }
+ // we need to take a snapshot so that the exported state can't be modified
+ // while the dialog is open
+ const [{ appStateSnapshot, elementsSnapshot }] = useState(() => {
+ return {
+ appStateSnapshot: cloneJSON(appState),
+ elementsSnapshot: cloneJSON(elements),
+ };
+ });
return (