mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Add toast (#2772)
Co-authored-by: Lipis <lipiridis@gmail.com> Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
0bf6830373
commit
543c624405
10 changed files with 161 additions and 3 deletions
|
@ -158,6 +158,7 @@ import {
|
|||
import ContextMenu from "./ContextMenu";
|
||||
import LayerUI from "./LayerUI";
|
||||
import { Stats } from "./Stats";
|
||||
import { Toast } from "./Toast";
|
||||
|
||||
const { history } = createHistory();
|
||||
|
||||
|
@ -376,6 +377,12 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
onClose={this.toggleStats}
|
||||
/>
|
||||
)}
|
||||
{this.state.toastMessage !== null && (
|
||||
<Toast
|
||||
message={this.state.toastMessage}
|
||||
clearToast={this.clearToast}
|
||||
/>
|
||||
)}
|
||||
<main>
|
||||
<canvas
|
||||
id="canvas"
|
||||
|
@ -911,6 +918,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
this.canvas!,
|
||||
this.state,
|
||||
);
|
||||
this.setState({ toastMessage: t("toast.copyToClipboardAsPng") });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
this.setState({ errorMessage: error.message });
|
||||
|
@ -1168,6 +1176,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
});
|
||||
};
|
||||
|
||||
clearToast = () => {
|
||||
this.setState({ toastMessage: null });
|
||||
};
|
||||
|
||||
public updateScene = withBatchedUpdates((sceneData: SceneData) => {
|
||||
if (sceneData.commitToHistory) {
|
||||
history.resumeRecording();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue