fix(diagram): add missing Copy icon import for DiagramEditor export section
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
|||||||
Eye,
|
Eye,
|
||||||
AlertTriangle,
|
AlertTriangle,
|
||||||
FileText,
|
FileText,
|
||||||
|
Copy,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import ToolLayout from "../components/ToolLayout";
|
import ToolLayout from "../components/ToolLayout";
|
||||||
import CodeMirrorEditor from "../components/CodeMirrorEditor";
|
import CodeMirrorEditor from "../components/CodeMirrorEditor";
|
||||||
@@ -22,6 +23,7 @@ import RelatedTools from "../components/RelatedTools";
|
|||||||
import ReactFlowEditor from "../components/diagram/ReactFlowEditor";
|
import ReactFlowEditor from "../components/diagram/ReactFlowEditor";
|
||||||
import FullscreenAdBanner from "../components/FullscreenAdBanner";
|
import FullscreenAdBanner from "../components/FullscreenAdBanner";
|
||||||
import { toPng } from "html-to-image";
|
import { toPng } from "html-to-image";
|
||||||
|
import { generateMermaidFromGraph } from "../utils/mermaidGenerator";
|
||||||
|
|
||||||
const DIAGRAM_TEMPLATES = {
|
const DIAGRAM_TEMPLATES = {
|
||||||
flowchart: {
|
flowchart: {
|
||||||
@@ -214,6 +216,28 @@ const DiagramEditor = () => {
|
|||||||
downloadFile(code, "diagram.json", "application/json");
|
downloadFile(code, "diagram.json", "application/json");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const exportMermaid = () => {
|
||||||
|
const mermaidCode = generateMermaidFromGraph(
|
||||||
|
graphData.nodes,
|
||||||
|
graphData.edges,
|
||||||
|
);
|
||||||
|
downloadFile(mermaidCode, "diagram.mmd", "text/plain");
|
||||||
|
};
|
||||||
|
|
||||||
|
const copyMermaid = () => {
|
||||||
|
const mermaidCode = generateMermaidFromGraph(
|
||||||
|
graphData.nodes,
|
||||||
|
graphData.edges,
|
||||||
|
);
|
||||||
|
navigator.clipboard
|
||||||
|
.writeText(mermaidCode)
|
||||||
|
.then(() => {
|
||||||
|
// Could add toast notification here
|
||||||
|
console.log("Mermaid code copied!");
|
||||||
|
})
|
||||||
|
.catch((err) => console.error("Failed to copy", err));
|
||||||
|
};
|
||||||
|
|
||||||
const exportPNG = () => {
|
const exportPNG = () => {
|
||||||
const flowElement = document.querySelector(".react-flow");
|
const flowElement = document.querySelector(".react-flow");
|
||||||
if (!flowElement) return;
|
if (!flowElement) return;
|
||||||
@@ -503,7 +527,7 @@ const DiagramEditor = () => {
|
|||||||
Export Diagram
|
Export Diagram
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="p-4 sm:p-6 grid grid-cols-1 sm:grid-cols-2 gap-4">
|
<div className="p-4 sm:p-6 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4">
|
||||||
<button
|
<button
|
||||||
onClick={exportPNG}
|
onClick={exportPNG}
|
||||||
className="flex flex-col items-center p-4 border border-gray-200 dark:border-gray-700 rounded-lg hover:border-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-all group"
|
className="flex flex-col items-center p-4 border border-gray-200 dark:border-gray-700 rounded-lg hover:border-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-all group"
|
||||||
@@ -527,6 +551,28 @@ const DiagramEditor = () => {
|
|||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-gray-500">.json data format</span>
|
<span className="text-xs text-gray-500">.json data format</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={exportMermaid}
|
||||||
|
className="flex flex-col items-center p-4 border border-gray-200 dark:border-gray-700 rounded-lg hover:border-green-500 hover:bg-green-50 dark:hover:bg-green-900/20 transition-all group"
|
||||||
|
>
|
||||||
|
<FileCode2 className="h-6 w-6 text-gray-500 group-hover:text-green-500 mb-2" />
|
||||||
|
<span className="font-medium text-gray-900 dark:text-white">
|
||||||
|
Mermaid File
|
||||||
|
</span>
|
||||||
|
<span className="text-xs text-gray-500">.mmd raw code</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={copyMermaid}
|
||||||
|
className="flex flex-col items-center p-4 border border-gray-200 dark:border-gray-700 rounded-lg hover:border-orange-500 hover:bg-orange-50 dark:hover:bg-orange-900/20 transition-all group"
|
||||||
|
>
|
||||||
|
<Copy className="h-6 w-6 text-gray-500 group-hover:text-orange-500 mb-2" />
|
||||||
|
<span className="font-medium text-gray-900 dark:text-white">
|
||||||
|
Copy Mermaid
|
||||||
|
</span>
|
||||||
|
<span className="text-xs text-gray-500">To clipboard</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user