import { useMemo } from 'react'; import { darkTheme, GraphCanvas, GraphEdge, GraphNode, lightTheme } from 'reagraph'; import Modal from '../../components/Common/Modal'; import { useConceptTheme } from '../../context/ThemeContext'; import { resources } from '../../utils/constants'; import { SyntaxTree } from '../../utils/models'; import { getNodeLabel } from '../../utils/staticUI'; interface DlgShowASTProps { hideWindow: () => void syntaxTree: SyntaxTree expression: string } function DlgShowAST({ hideWindow, syntaxTree, expression }: DlgShowASTProps) { const { darkMode } = useConceptTheme(); function handleSubmit() { // Do nothing } const nodes: GraphNode[] = useMemo( () => syntaxTree.map(node => { return { id: String(node.uid), label: getNodeLabel(node) }; }), [syntaxTree]); const edges: GraphEdge[] = useMemo( () => { const result: GraphEdge[] = []; syntaxTree.forEach(node => { if (node.parent != node.uid) { result.push({ id: String(node.uid), source: String(node.parent), target: String(node.uid) }); } }); return result; }, [syntaxTree]); return (
{expression}
); } export default DlgShowAST;