1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2024-11-10 11:35:52 +01:00

better api

This commit is contained in:
Aakansha Doshi 2023-09-22 11:22:39 +05:30
parent 8654958aba
commit e1b0b559f5
3 changed files with 7 additions and 19 deletions

@ -1192,10 +1192,7 @@ class App extends React.Component<AppProps, AppState> {
>
{this.props.children}
{this.state.activeTool.type === "mermaid" && (
<MermaidToExcalidraw
appState={this.state}
elements={this.scene.getNonDeletedElements()}
/>
<MermaidToExcalidraw />
)}
</LayerUI>
@ -3107,7 +3104,7 @@ class App extends React.Component<AppProps, AppState> {
}
});
private setActiveTool = (
public setActiveTool = (
tool:
| {
type:

@ -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);
};

@ -533,6 +533,7 @@ export type AppClassProperties = {
addFiles: App["addFiles"];
setSelection: App["setSelection"];
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
setActiveTool: App["setActiveTool"];
};
export type PointerDownState = Readonly<{