2023-09-19 20:46:50 +08:00
|
|
|
import { React } from "react";
|
2023-09-19 20:46:46 +08:00
|
|
|
import Diagram from "../components/diagram";
|
2023-09-19 20:46:48 +08:00
|
|
|
import Header from "../components/header";
|
|
|
|
import Sidebar from "../components/sidebar";
|
2023-09-19 20:46:46 +08:00
|
|
|
import { ResizableBox } from "react-resizable";
|
|
|
|
import "react-resizable/css/styles.css";
|
2023-09-19 20:46:48 +08:00
|
|
|
import ControlPanel from "../components/control_panel";
|
2023-09-19 20:46:50 +08:00
|
|
|
import CodeMirror from "@uiw/react-codemirror";
|
|
|
|
import { createTheme } from "@uiw/codemirror-themes";
|
|
|
|
import { sql } from "@codemirror/lang-sql";
|
|
|
|
import { tags as t } from "@lezer/highlight";
|
|
|
|
|
|
|
|
const myTheme = createTheme({
|
|
|
|
dark: "light",
|
|
|
|
settings: {},
|
|
|
|
styles: [
|
|
|
|
{ tag: t.comment, color: "#8ab0ed" },
|
|
|
|
{ tag: t.string, color: "#e68e29" },
|
|
|
|
{ tag: t.number, color: "#e68e29" },
|
|
|
|
{ tag: t.keyword, color: "#295be6" },
|
|
|
|
{ tag: t.variableName, color: "#1a00db" },
|
|
|
|
{ tag: t.typeName, color: "#295be6" },
|
|
|
|
{ tag: t.tagName, color: "#008a02" },
|
|
|
|
],
|
|
|
|
});
|
2023-09-19 20:46:46 +08:00
|
|
|
|
|
|
|
export default function Editor(props) {
|
|
|
|
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:46 +08:00
|
|
|
<ResizableBox
|
|
|
|
width={window.innerWidth * 0.2}
|
|
|
|
height={window.innerHeight}
|
|
|
|
resizeHandles={["e"]}
|
|
|
|
minConstraints={[window.innerWidth * 0.2, window.innerHeight]}
|
|
|
|
maxConstraints={[Infinity, Infinity]}
|
|
|
|
axis="x"
|
|
|
|
>
|
2023-09-19 20:46:50 +08:00
|
|
|
<div className="overflow-auto h-full">
|
|
|
|
<CodeMirror
|
|
|
|
height="100%"
|
|
|
|
theme={myTheme}
|
|
|
|
extensions={[sql()]}
|
|
|
|
onChange={(value, viewUpdate) => {
|
|
|
|
console.log("value:", value);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-09-19 20:46:46 +08:00
|
|
|
</ResizableBox>
|
2023-09-19 20:46:48 +08:00
|
|
|
<div className="flex-grow">
|
2023-09-19 20:46:46 +08:00
|
|
|
<Diagram />
|
|
|
|
</div>
|
2023-09-19 20:46:50 +08:00
|
|
|
<Sidebar />
|
2023-09-19 20:46:46 +08:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|