2023-09-19 20:47:01 +08:00
|
|
|
import { React, useState, useMemo } from "react";
|
2023-09-19 20:46:48 +08:00
|
|
|
import Header from "../components/header";
|
|
|
|
import Sidebar from "../components/sidebar";
|
|
|
|
import ControlPanel from "../components/control_panel";
|
2023-09-19 20:47:01 +08:00
|
|
|
import { DndProvider } from "react-dnd";
|
2023-09-19 20:46:54 +08:00
|
|
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
2023-09-19 20:47:01 +08:00
|
|
|
import { dia } from "jointjs";
|
|
|
|
import DrawArea from "../components/draw_area";
|
|
|
|
import EditorPanel from "../components/editor_panel";
|
2023-09-19 20:46:54 +08:00
|
|
|
|
2023-09-19 20:46:46 +08:00
|
|
|
export default function Editor(props) {
|
2023-09-19 20:46:54 +08:00
|
|
|
const graph = useMemo(() => new dia.Graph(), []);
|
2023-09-19 20:46:56 +08:00
|
|
|
const [code, setCode] = useState("");
|
|
|
|
|
2023-09-19 20:46:46 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Header name={props.name} />
|
2023-09-19 20:46:50 +08:00
|
|
|
<ControlPanel />
|
2023-09-19 20:46:48 +08:00
|
|
|
<div className="flex h-full">
|
2023-09-19 20:46:58 +08:00
|
|
|
<DndProvider backend={HTML5Backend}>
|
2023-09-19 20:47:01 +08:00
|
|
|
<EditorPanel graph={graph} code={code} setCode={setCode}/>
|
|
|
|
<DrawArea graph={graph} code={code} setCode={setCode}/>
|
2023-09-19 20:46:58 +08:00
|
|
|
</DndProvider>
|
2023-09-19 20:46:50 +08:00
|
|
|
<Sidebar />
|
2023-09-19 20:46:46 +08:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|