mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-12-23 02:01:19 +08:00
Abstract areas
This commit is contained in:
@@ -13,11 +13,12 @@ import {
|
||||
defaultTableTheme,
|
||||
State,
|
||||
} from "../data/data";
|
||||
import { AreaContext, StateContext, TabContext } from "../pages/Editor";
|
||||
import { StateContext, TabContext } from "../pages/Editor";
|
||||
import useLayout from "../hooks/useLayout";
|
||||
import useSettings from "../hooks/useSettings";
|
||||
import useUndoRedo from "../hooks/useUndoRedo";
|
||||
import useSelect from "../hooks/useSelect";
|
||||
import useAreas from "../hooks/useAreas";
|
||||
|
||||
export default function Area(props) {
|
||||
const [hovered, setHovered] = useState(false);
|
||||
@@ -26,7 +27,7 @@ export default function Area(props) {
|
||||
const { layout } = useLayout();
|
||||
const { settings } = useSettings();
|
||||
const { tab, setTab } = useContext(TabContext);
|
||||
const { updateArea, deleteArea } = useContext(AreaContext);
|
||||
const { updateArea, deleteArea } = useAreas();
|
||||
const { setUndoStack, setRedoStack } = useUndoRedo();
|
||||
const { selectedElement, setSelectedElement } = useSelect();
|
||||
|
||||
|
||||
@@ -26,12 +26,13 @@ import {
|
||||
ObjectType,
|
||||
State,
|
||||
} from "../data/data";
|
||||
import { AreaContext, StateContext } from "../pages/Editor";
|
||||
import { StateContext } from "../pages/Editor";
|
||||
import useUndoRedo from "../hooks/useUndoRedo";
|
||||
import useAreas from "../hooks/useAreas";
|
||||
|
||||
export default function AreaOverview() {
|
||||
const { setState } = useContext(StateContext);
|
||||
const { areas, addArea, deleteArea, updateArea } = useContext(AreaContext);
|
||||
const { areas, addArea, deleteArea, updateArea } = useAreas();
|
||||
const { setUndoStack, setRedoStack } = useUndoRedo();
|
||||
const [editField, setEditField] = useState({});
|
||||
const [value, setValue] = useState("");
|
||||
|
||||
@@ -3,7 +3,7 @@ import Table from "./Table";
|
||||
import { Action, Cardinality, Constraint, ObjectType } from "../data/data";
|
||||
import Area from "./Area";
|
||||
import Relationship from "./Relationship";
|
||||
import { AreaContext, NoteContext } from "../pages/Editor";
|
||||
import { NoteContext } from "../pages/Editor";
|
||||
import Note from "./Note";
|
||||
import { Toast } from "@douyinfe/semi-ui";
|
||||
import useSettings from "../hooks/useSettings";
|
||||
@@ -11,10 +11,11 @@ import useTransform from "../hooks/useTransform";
|
||||
import useTables from "../hooks/useTables";
|
||||
import useUndoRedo from "../hooks/useUndoRedo";
|
||||
import useSelect from "../hooks/useSelect";
|
||||
import useAreas from "../hooks/useAreas";
|
||||
|
||||
export default function Canvas() {
|
||||
const { tables, updateTable, relationships, addRelationship } = useTables();
|
||||
const { areas, updateArea } = useContext(AreaContext);
|
||||
const { areas, updateArea } = useAreas();
|
||||
const { notes, updateNote } = useContext(NoteContext);
|
||||
const { settings } = useSettings();
|
||||
const { setUndoStack, setRedoStack } = useUndoRedo();
|
||||
|
||||
@@ -44,7 +44,6 @@ import {
|
||||
jsonToSQLServer,
|
||||
} from "../utils/toSQL";
|
||||
import {
|
||||
AreaContext,
|
||||
NoteContext,
|
||||
StateContext,
|
||||
TabContext,
|
||||
@@ -71,6 +70,7 @@ import useSelect from "../hooks/useSelect";
|
||||
import { enterFullscreen, exitFullscreen } from "../utils/fullscreen";
|
||||
import { ddbDiagramIsValid, jsonDiagramIsValid } from "../utils/validateSchema";
|
||||
import { dataURItoBlob } from "../utils/utils";
|
||||
import useAreas from "../hooks/useAreas";
|
||||
|
||||
export default function ControlPanel({
|
||||
diagramId,
|
||||
@@ -139,8 +139,7 @@ export default function ControlPanel({
|
||||
useContext(TypeContext);
|
||||
const { notes, setNotes, updateNote, addNote, deleteNote } =
|
||||
useContext(NoteContext);
|
||||
const { areas, setAreas, updateArea, addArea, deleteArea } =
|
||||
useContext(AreaContext);
|
||||
const { areas, setAreas, updateArea, addArea, deleteArea } = useAreas();
|
||||
const { undoStack, redoStack, setUndoStack, setRedoStack } = useUndoRedo();
|
||||
const { selectedElement, setSelectedElement } = useSelect();
|
||||
const { tab, setTab } = useContext(TabContext);
|
||||
|
||||
Reference in New Issue
Block a user