import { atom, useAtom } from "jotai"; import { actionClearCanvas } from "../actions"; import { t } from "../i18n"; import { jotaiScope } from "../jotai"; import { useExcalidrawActionManager } from "./App"; import ConfirmDialog from "./ConfirmDialog"; export const activeConfirmDialogAtom = atom<"clearCanvas" | null>(null); export const ActiveConfirmDialog = () => { const [activeConfirmDialog, setActiveConfirmDialog] = useAtom( activeConfirmDialogAtom, jotaiScope, ); const actionManager = useExcalidrawActionManager(); if (!activeConfirmDialog) { return null; } if (activeConfirmDialog === "clearCanvas") { return ( { actionManager.executeAction(actionClearCanvas); setActiveConfirmDialog(null); }} onCancel={() => setActiveConfirmDialog(null)} title={t("clearCanvasDialog.title")} >

{t("alerts.clearReset")}

); } return null; };