Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
},
"dependencies": {
"axios": "^1.10.0",
"file-saver": "^2.0.5",
"html2canvas": "^1.4.1",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"reactflow": "^11.11.4"
Expand Down
28 changes: 28 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import ReactFlow, {
} from 'reactflow';
import 'reactflow/dist/style.css';
import axios from 'axios';
import html2canvas from 'html2canvas';
import { saveAs } from 'file-saver';

// 🧠 Initial State & Helpers
const initialNodes = [];
Expand Down Expand Up @@ -155,6 +157,17 @@ export default function App() {
setLoading(false);
};

const handleExport = () => {
const reactflowWrapper = document.querySelector('.react-flow');
if (reactflowWrapper) {
html2canvas(reactflowWrapper).then((canvas) => {
canvas.toBlob((blob) => {
saveAs(blob, 'mind-map.png');
});
});
}
};

return (
<div style={{ height: '100vh', width: '100vw', backgroundColor: '#111', display: 'flex', flexDirection: 'column' }}>
{/* 🔝 Header */}
Expand Down Expand Up @@ -217,12 +230,27 @@ export default function App() {
>
⏹ Stop
</button>
<button
onClick={handleExport}
style={{
padding: '10px 20px',
backgroundColor: '#4CAF50',
color: 'white',
border: 'none',
borderRadius: '8px',
fontWeight: 'bold',
cursor: 'pointer',
}}
>
Export as PNG
</button>
</div>
</div>

{/* 🧠 ReactFlow Canvas */}
<div style={{ flexGrow: 1 }}>
<ReactFlow
className="react-flow"
nodes={nodes}
edges={edges}
onNodesChange={(changes) => setNodes((nds) => applyNodeChanges(changes, nds))}
Expand Down