From b8ae1d248665b062f474ed4a2e74fa1ac82b7574 Mon Sep 17 00:00:00 2001 From: zsviczian Date: Tue, 26 Sep 2023 21:37:13 +0200 Subject: [PATCH] setActiveTool - do not clear selectedElementIds so customData of image can be used & do not render when deferredText is empty --- src/components/App.tsx | 10 ++++++++-- src/components/MermaidToExcalidraw.tsx | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 8a44a3e88..e5d805310 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -3116,7 +3116,8 @@ class App extends React.Component { | "eraser" | "hand" | "frame" - | "embeddable"; + | "embeddable" + | "mermaid"; } | { type: "custom"; customType: string }, ) => { @@ -3138,7 +3139,12 @@ class App extends React.Component { if (nextActiveTool.type !== "selection") { this.setState({ activeTool: nextActiveTool, - selectedElementIds: makeNextSelectedElementIds({}, this.state), + selectedElementIds: makeNextSelectedElementIds( + nextActiveTool.type === "mermaid" + ? this.state.selectedElementIds + : {}, + this.state, + ), selectedGroupIds: {}, editingGroupId: null, activeEmbeddable: null, diff --git a/src/components/MermaidToExcalidraw.tsx b/src/components/MermaidToExcalidraw.tsx index 0d6ad329b..bd861946e 100644 --- a/src/components/MermaidToExcalidraw.tsx +++ b/src/components/MermaidToExcalidraw.tsx @@ -129,7 +129,11 @@ const MermaidToExcalidraw = ({ useEffect(() => { const renderExcalidrawPreview = async () => { const canvasNode = canvasRef.current; - if (!canvasNode || !mermaidToExcalidrawLib.current) { + if ( + !canvasNode || + !mermaidToExcalidrawLib.current || + deferredText === "" + ) { return; } try {