reset preview when error
This commit is contained in:
parent
21a804a4e5
commit
f696d36e03
@ -79,6 +79,10 @@ const MermaidToExcalidraw = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const convertMermaidToExcal = async () => {
|
const convertMermaidToExcal = async () => {
|
||||||
let mermaidGraphData;
|
let mermaidGraphData;
|
||||||
|
const canvasNode = canvasRef.current;
|
||||||
|
if (!canvasNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
mermaidGraphData = await mermaidToExcalidrawLib.current.parseMermaid(
|
mermaidGraphData = await mermaidToExcalidrawLib.current.parseMermaid(
|
||||||
text,
|
text,
|
||||||
@ -87,7 +91,8 @@ const MermaidToExcalidraw = ({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Parse error, displaying error message to users
|
console.error(e);
|
||||||
|
canvasNode.replaceChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mermaidGraphData) {
|
if (mermaidGraphData) {
|
||||||
@ -99,10 +104,6 @@ const MermaidToExcalidraw = ({
|
|||||||
files,
|
files,
|
||||||
};
|
};
|
||||||
|
|
||||||
const canvasNode = canvasRef.current;
|
|
||||||
if (!canvasNode) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const maxWidth = canvasNode.offsetWidth;
|
const maxWidth = canvasNode.offsetWidth;
|
||||||
const maxHeight = canvasNode.offsetHeight;
|
const maxHeight = canvasNode.offsetHeight;
|
||||||
let dimension = Math.max(maxWidth, maxHeight);
|
let dimension = Math.max(maxWidth, maxHeight);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user