瀏覽代碼

setActiveTool - do not clear selectedElementIds so customData of image can be used & do not render when deferredText is empty

zsviczian 1 年之前
父節點
當前提交
b8ae1d2486
共有 2 個文件被更改,包括 13 次插入3 次删除
  1. 8 2
      src/components/App.tsx
  2. 5 1
      src/components/MermaidToExcalidraw.tsx

+ 8 - 2
src/components/App.tsx

@@ -3116,7 +3116,8 @@ class App extends React.Component<AppProps, AppState> {
             | "eraser"
             | "hand"
             | "frame"
-            | "embeddable";
+            | "embeddable"
+            | "mermaid";
         }
       | { type: "custom"; customType: string },
   ) => {
@@ -3138,7 +3139,12 @@ class App extends React.Component<AppProps, AppState> {
     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,

+ 5 - 1
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 {