mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
reset preview when error
This commit is contained in:
parent
21a804a4e5
commit
f696d36e03
1 changed files with 6 additions and 5 deletions
|
@ -79,6 +79,10 @@ const MermaidToExcalidraw = ({
|
|||
useEffect(() => {
|
||||
const convertMermaidToExcal = async () => {
|
||||
let mermaidGraphData;
|
||||
const canvasNode = canvasRef.current;
|
||||
if (!canvasNode) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
mermaidGraphData = await mermaidToExcalidrawLib.current.parseMermaid(
|
||||
text,
|
||||
|
@ -87,7 +91,8 @@ const MermaidToExcalidraw = ({
|
|||
},
|
||||
);
|
||||
} catch (e) {
|
||||
// Parse error, displaying error message to users
|
||||
console.error(e);
|
||||
canvasNode.replaceChildren();
|
||||
}
|
||||
|
||||
if (mermaidGraphData) {
|
||||
|
@ -99,10 +104,6 @@ const MermaidToExcalidraw = ({
|
|||
files,
|
||||
};
|
||||
|
||||
const canvasNode = canvasRef.current;
|
||||
if (!canvasNode) {
|
||||
return;
|
||||
}
|
||||
const maxWidth = canvasNode.offsetWidth;
|
||||
const maxHeight = canvasNode.offsetHeight;
|
||||
let dimension = Math.max(maxWidth, maxHeight);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue