react-whiteboard-flow
Version:
A React component for a whiteboard with drawing, erasing, and JS code-to-flowchart visualization.
93 lines (69 loc) โข 2.2 kB
Markdown
A React component for a whiteboard with drawing, erasing, and JavaScript code-to-flowchart visualization.



- โ๏ธ Freehand drawing with pencil tool
- ๐งฝ Erasing tool
- ๐ Canvas reset
- ๐ง Convert JavaScript code to a flowchart using `js2flowchart`
```
npm install react-whiteboard-flow
```
or
```
yarn add react-whiteboard-flow
```
Import and use the `WhiteboardFlow` component in your React app:
```jsx
import React from "react";
import WhiteboardFlow from "react-whiteboard-flow";
import "./App.css";
function App() {
const exampleCode = `
const doStuff = (stuff) => {
if (stuff) {
if (devFlag) {
log('perf start');
doRecursion();
log('perf end');
return;
}
doRecursion();
end();
} else {
throw new Error('No stuff!');
}
return null;
};
`;
return (
<div className="whiteboard-container">
<WhiteboardFlow
width="360"
height="650"
code={exampleCode}
className="canvas"
/>
</div>
);
}
export default App;
```
- `width` (number or string): Canvas width (default: 360)
- `height` (number or string): Canvas height (default: 650)
- `code` (string): JavaScript code to visualize as a flowchart
- `className` (string): CSS class for the canvas
## ๐น๏ธ Controls
- โ๏ธ **Pencil** โ Draw freely on the canvas using the mouse
- ๐งฝ **Eraser** โ Erase selected parts of your drawing
- ๐งน **Reset** โ Clear the entire canvas
- ๐ง **Flowchart** โ Generate and toggle a flowchart from the provided JavaScript code
## Contributing
Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request on [GitHub](https://github.com/Arun-kumar2206/react-whiteboard-flow).
## License
MIT