"use client"; import { DrawIoEmbed, DrawIoEmbedRef } from "react-drawio"; import { useRef, useState } from "react"; import { Button } from "@/components/ui/button"; import { extractDiagramXML } from "./extract_xml"; import ChatPanel from "@/components/chatPanel"; export default function Home() { const drawioRef = useRef(null); const [chartXML, setChartXML] = useState(""); const handleExport = () => { if (drawioRef.current) { drawioRef.current.exportDiagram({ format: "xmlsvg", }); } console.log("chartXML from page", chartXML); }; const loadDiagram = (chart: string) => { if (drawioRef.current) { drawioRef.current.load({ xml: chart, }); } }; return (
setChartXML(extractDiagramXML(data.data))} urlParameters={{ spin: true, libraries: false, saveAndExit: false, noExitBtn: true, }} />
loadDiagram(xml)} onFetchChart={() => { handleExport(); console.log("chartXML from page", chartXML); return chartXML; }} />
); }