-
-
Notifications
You must be signed in to change notification settings - Fork 198
Closed
Description
Hello!
I have a problem with the mermaid plugin. When I start erasing the word 'mermaid' in the editor, I get an error like in the screenshot.
here is my code component
export const Code = ({ inline, children = [], className, ...props }: any) => {
const mermaidGraphId = useRef(`mermaidGraph${randomId()}`);
const code = getCode(children);
const mermaidGraph = useRef(null);
const handle = useCallback(async () => {
if (mermaidGraph.current) {
try {
const { svg } = await mermaid.render(
mermaidGraphId.current,
code
);
mermaidGraph.current.innerHTML = svg;
} catch (error) {
mermaidGraph.current.innerHTML = error;
}
}
}, [mermaidGraph, code]);
useEffect(() => {
handle();
}, [handle]);
if (
typeof code === 'string' &&
typeof className === 'string' &&
/^language-mermaid/.test(className.toLocaleLowerCase())
) {
return (
<code ref={mermaidGraph}>
<code id={mermaidGraphId.current} style={{ display: 'none' }} />
</code>
);
}
return <code className={String(className)}>{children}</code>;
};and MDEditor component
<MDEditor
height={400}
value={text}
onChange={text => {
setText(text);
setFieldValue('text', text);
}}
previewOptions={{
components: {
code: Code,
img: Image
}
}}
/>Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
