Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

i dont remember what

1ilit65a33e1fc366
diff --git a/src/components/draw_area.jsx b/src/components/draw_area.jsx
index 6982d202..cb19e99e 100644
--- a/src/components/draw_area.jsx
+++ b/src/components/draw_area.jsx
@@ -55,6 +55,11 @@ export default function Canvas(props) {
label: `rect ${props.rectangles.length + 1}`,
};
props.setRectangles([...props.rectangles, newRectangle]);
+ props.setCode((prev) =>
+ prev === ""
+ ? `CREATE TABLE \`${newRectangle.label}\`;`
+ : `${prev}\n\nCREATE TABLE \`${newRectangle.label}\`;`
+ );
},
collect: (monitor) => ({
isOver: !!monitor.isOver(),
diff --git a/src/components/editor_panel.jsx b/src/components/editor_panel.jsx
index f951bed2..81b06fee 100644
--- a/src/components/editor_panel.jsx
+++ b/src/components/editor_panel.jsx
@@ -57,6 +57,11 @@ export default function EditorPanel(props) {
label: `rect ${props.rectangles.length + 1}`,
};
props.setRectangles([...props.rectangles, newRectangle]);
+ props.setCode((prev) =>
+ prev === ""
+ ? `CREATE TABLE \`${newRectangle.label}\`;`
+ : `${prev}\n\nCREATE TABLE \`${newRectangle.label}\`;`
+ );
}}
>
add
diff --git a/src/components/rect.jsx b/src/components/rect.jsx
index f8b86ac7..ecd87da6 100644
--- a/src/components/rect.jsx
+++ b/src/components/rect.jsx
@@ -1,9 +1,10 @@
import React from "react";
+import { Button } from "@arco-design/web-react";
const Rect = (props) => {
return (
<g>
- <rect
+ <foreignObject
key={props.id}
x={props.x}
y={props.y}
@@ -11,13 +12,16 @@ const Rect = (props) => {
height={props.height}
style={{ fill: "blue", cursor: "move" }}
onMouseDown={props.onMouseDown}
- />
- <foreignObject x={props.x + 10} y={props.y + 25} width={80} height={50}>
- <body xmlns="http://www.w3.org/1999/xhtml">
+ >
+ <div xmlns="http://www.w3.org/1999/xhtml" className="bg-blue p-3">
+ <div className="text-white">{props.label}</div>
<form onSubmit={(e) => e.preventDefault()}>
<input type="text" className="w-full" />
</form>
- </body>
+ <Button type="secondary" onClick={(e) => console.log("sup")}>
+ sup
+ </Button>
+ </div>
</foreignObject>
</g>
);