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

This commit is contained in:
zsviczian 2023-09-26 21:37:13 +02:00 committed by GitHub
parent 482178b7b6
commit b8ae1d2486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -3116,7 +3116,8 @@ class App extends React.Component<AppProps, AppState> {
| "eraser" | "eraser"
| "hand" | "hand"
| "frame" | "frame"
| "embeddable"; | "embeddable"
| "mermaid";
} }
| { type: "custom"; customType: string }, | { type: "custom"; customType: string },
) => { ) => {
@ -3138,7 +3139,12 @@ class App extends React.Component<AppProps, AppState> {
if (nextActiveTool.type !== "selection") { if (nextActiveTool.type !== "selection") {
this.setState({ this.setState({
activeTool: nextActiveTool, activeTool: nextActiveTool,
selectedElementIds: makeNextSelectedElementIds({}, this.state), selectedElementIds: makeNextSelectedElementIds(
nextActiveTool.type === "mermaid"
? this.state.selectedElementIds
: {},
this.state,
),
selectedGroupIds: {}, selectedGroupIds: {},
editingGroupId: null, editingGroupId: null,
activeEmbeddable: null, activeEmbeddable: null,

View File

@ -129,7 +129,11 @@ const MermaidToExcalidraw = ({
useEffect(() => { useEffect(() => {
const renderExcalidrawPreview = async () => { const renderExcalidrawPreview = async () => {
const canvasNode = canvasRef.current; const canvasNode = canvasRef.current;
if (!canvasNode || !mermaidToExcalidrawLib.current) { if (
!canvasNode ||
!mermaidToExcalidrawLib.current ||
deferredText === ""
) {
return; return;
} }
try { try {