diff --git a/src/components/App.tsx b/src/components/App.tsx index 9d922cffd..a0a5ad184 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1192,10 +1192,7 @@ class App extends React.Component { > {this.props.children} {this.state.activeTool.type === "mermaid" && ( - + )} @@ -3107,7 +3104,7 @@ class App extends React.Component { } }); - private setActiveTool = ( + public setActiveTool = ( tool: | { type: diff --git a/src/components/MermaidToExcalidraw.tsx b/src/components/MermaidToExcalidraw.tsx index 09b153b5c..6c88ebebc 100644 --- a/src/components/MermaidToExcalidraw.tsx +++ b/src/components/MermaidToExcalidraw.tsx @@ -1,7 +1,6 @@ import { useState, useRef, useEffect, useDeferredValue } from "react"; -import { AppState, BinaryFiles } from "../types"; -import { updateActiveTool } from "../utils"; -import { useApp, useExcalidrawSetAppState } from "./App"; +import { BinaryFiles } from "../types"; +import { useApp } from "./App"; import { Button } from "./Button"; import { Dialog } from "./Dialog"; import { DEFAULT_EXPORT_PADDING, DEFAULT_FONT_SIZE } from "../constants"; @@ -65,13 +64,7 @@ const ErrorComp = ({ error }: { error: string }) => { ); }; -const MermaidToExcalidraw = ({ - appState, - elements, -}: { - appState: AppState; - elements: readonly NonDeletedExcalidrawElement[]; -}) => { +const MermaidToExcalidraw = () => { const mermaidToExcalidrawLib = useRef<{ parseMermaidToExcalidraw: ( defination: string, @@ -174,11 +167,8 @@ const MermaidToExcalidraw = ({ renderExcalidrawPreview(); }, [deferredText]); - const setAppState = useExcalidrawSetAppState(); - const onClose = () => { - const activeTool = updateActiveTool(appState, { type: "selection" }); - setAppState({ activeTool }); + app.setActiveTool({ type: "selection" }); saveMermaidDataToStorage(text); }; diff --git a/src/types.ts b/src/types.ts index 1bf267d2c..da01861b0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -533,6 +533,7 @@ export type AppClassProperties = { addFiles: App["addFiles"]; setSelection: App["setSelection"]; addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"]; + setActiveTool: App["setActiveTool"]; }; export type PointerDownState = Readonly<{