2025-03-19 06:04:06 +00:00
|
|
|
"use client";
|
|
|
|
|
import { DrawIoEmbed, DrawIoEmbedRef } from "react-drawio";
|
|
|
|
|
|
|
|
|
|
import { useRef, useState } from "react";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
2025-03-19 07:20:22 +00:00
|
|
|
import { extractDiagramXML } from "./extract_xml";
|
|
|
|
|
import ChatPanel from "@/components/chatPanel";
|
2025-03-19 06:04:06 +00:00
|
|
|
|
2025-03-19 07:20:22 +00:00
|
|
|
export default function Home() {
|
2025-03-19 06:04:06 +00:00
|
|
|
const drawioRef = useRef<DrawIoEmbedRef>(null);
|
2025-03-19 07:20:22 +00:00
|
|
|
const [chartXML, setChartXML] = useState<string>("");
|
2025-03-19 06:04:06 +00:00
|
|
|
const [diagram, setDiagram] = useState<string>("");
|
|
|
|
|
// const handleExport = () => {};
|
|
|
|
|
const handleExport = () => {
|
2025-03-19 07:20:22 +00:00
|
|
|
// use this function to export the diagramxml from the drawio editor
|
2025-03-19 06:04:06 +00:00
|
|
|
if (drawioRef.current) {
|
|
|
|
|
drawioRef.current.exportDiagram({
|
|
|
|
|
format: "xmlsvg",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-03-19 07:20:22 +00:00
|
|
|
const loadDiagram = (chart: string) => {
|
|
|
|
|
// use this function to display the diagramxml in the drawio editor
|
2025-03-19 06:04:06 +00:00
|
|
|
if (drawioRef.current) {
|
|
|
|
|
drawioRef.current.load({
|
2025-03-19 07:20:22 +00:00
|
|
|
xml: chart,
|
2025-03-19 06:04:06 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return (
|
2025-03-19 07:20:22 +00:00
|
|
|
<div className="flex h-screen bg-gray-100">
|
|
|
|
|
<div className="w-2/3 p-1">
|
2025-03-19 06:04:06 +00:00
|
|
|
<DrawIoEmbed
|
|
|
|
|
ref={drawioRef}
|
2025-03-19 07:20:22 +00:00
|
|
|
onExport={(data) => setChartXML(extractDiagramXML(data.data))}
|
2025-03-19 06:04:06 +00:00
|
|
|
urlParameters={{
|
|
|
|
|
// ui: "kennedy",
|
|
|
|
|
spin: true,
|
|
|
|
|
libraries: false,
|
|
|
|
|
saveAndExit: false,
|
|
|
|
|
noExitBtn: true,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-03-19 07:20:22 +00:00
|
|
|
<div className="w-1/3 p-1 border-gray-300 ">
|
|
|
|
|
<ChatPanel />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-03-19 06:04:06 +00:00
|
|
|
);
|
|
|
|
|
}
|