diff --git a/src/components/ExportDialog.tsx b/src/components/ExportDialog.tsx index 4eba444c7..0acc30ca8 100644 --- a/src/components/ExportDialog.tsx +++ b/src/components/ExportDialog.tsx @@ -28,7 +28,7 @@ type ExportCB = ( scale?: number, ) => void; -export function ExportDialog({ +function ExportModal({ elements, appState, exportPadding = 10, @@ -37,6 +37,7 @@ export function ExportDialog({ onExportToPng, onExportToClipboard, onExportToBackend, + onCloseRequest, }: { appState: AppState; elements: readonly ExcalidrawElement[]; @@ -46,10 +47,10 @@ export function ExportDialog({ onExportToPng: ExportCB; onExportToClipboard: ExportCB; onExportToBackend: ExportCB; + onCloseRequest: () => void; }) { const { t } = useTranslation(); const someElementIsSelected = elements.some(element => element.isSelected); - const [modalIsShown, setModalIsShown] = useState(false); const [scale, setScale] = useState(defaultScale); const [exportSelected, setExportSelected] = useState(someElementIsSelected); const previewRef = useRef(null); @@ -76,7 +77,6 @@ export function ExportDialog({ previewNode?.removeChild(canvas); }; }, [ - modalIsShown, exportedElements, exportBackground, exportPadding, @@ -84,10 +84,113 @@ export function ExportDialog({ scale, ]); - function handleClose() { - setModalIsShown(false); - setExportSelected(someElementIsSelected); - } + return ( +
+ + +

{t("buttons.export")}

+
+
+ + onExportToPng(exportedElements, scale)} + /> + {probablySupportsClipboard && ( + onExportToClipboard(exportedElements, scale)} + /> + )} + onExportToBackend(exportedElements)} + /> + + + {actionManager.renderAction( + "changeProjectName", + elements, + appState, + syncActionResult, + t, + )} + +
+ + {scales.map(s => ( + setScale(s)} + /> + ))} + +
+ {actionManager.renderAction( + "changeExportBackground", + elements, + appState, + syncActionResult, + t, + )} + {someElementIsSelected && ( +
+ +
+ )} +
+
+
+
+ ); +} + +export function ExportDialog({ + elements, + appState, + exportPadding = 10, + actionManager, + syncActionResult, + onExportToPng, + onExportToClipboard, + onExportToBackend, +}: { + appState: AppState; + elements: readonly ExcalidrawElement[]; + exportPadding?: number; + actionManager: ActionsManagerInterface; + syncActionResult: UpdaterFn; + onExportToPng: ExportCB; + onExportToClipboard: ExportCB; + onExportToBackend: ExportCB; +}) { + const { t } = useTranslation(); + const [modalIsShown, setModalIsShown] = useState(false); return ( <> @@ -99,93 +202,18 @@ export function ExportDialog({ title={t("buttons.export")} /> {modalIsShown && ( - -
- - -

{t("buttons.export")}

-
-
- - onExportToPng(exportedElements, scale)} - /> - {probablySupportsClipboard && ( - - onExportToClipboard(exportedElements, scale) - } - /> - )} - onExportToBackend(exportedElements)} - /> - - - {actionManager.renderAction( - "changeProjectName", - elements, - appState, - syncActionResult, - t, - )} - -
- - {scales.map(s => ( - setScale(s)} - /> - ))} - -
- {actionManager.renderAction( - "changeExportBackground", - elements, - appState, - syncActionResult, - t, - )} - {someElementIsSelected && ( -
- -
- )} -
-
-
-
+ setModalIsShown(false)}> + setModalIsShown(false)} + /> )}