mirror of
https://github.com/drawdb-io/drawdb.git
synced 2026-02-12 02:00:40 +08:00
Abstract notes out of editor
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { useContext, useRef, useState, useEffect } from "react";
|
||||
import { useRef, useState, useEffect } from "react";
|
||||
import Table from "./Table";
|
||||
import { Action, Cardinality, Constraint, ObjectType } from "../data/data";
|
||||
import Area from "./Area";
|
||||
import Relationship from "./Relationship";
|
||||
import { NoteContext } from "../pages/Editor";
|
||||
import Note from "./Note";
|
||||
import { Toast } from "@douyinfe/semi-ui";
|
||||
import useSettings from "../hooks/useSettings";
|
||||
@@ -12,11 +11,12 @@ import useTables from "../hooks/useTables";
|
||||
import useUndoRedo from "../hooks/useUndoRedo";
|
||||
import useSelect from "../hooks/useSelect";
|
||||
import useAreas from "../hooks/useAreas";
|
||||
import useNotes from "../hooks/useNotes";
|
||||
|
||||
export default function Canvas() {
|
||||
const { tables, updateTable, relationships, addRelationship } = useTables();
|
||||
const { areas, updateArea } = useAreas();
|
||||
const { notes, updateNote } = useContext(NoteContext);
|
||||
const { notes, updateNote } = useNotes();
|
||||
const { settings } = useSettings();
|
||||
const { setUndoStack, setRedoStack } = useUndoRedo();
|
||||
const { transform, setTransform } = useTransform();
|
||||
|
||||
@@ -44,7 +44,6 @@ import {
|
||||
jsonToSQLServer,
|
||||
} from "../utils/toSQL";
|
||||
import {
|
||||
NoteContext,
|
||||
StateContext,
|
||||
TabContext,
|
||||
TypeContext,
|
||||
@@ -71,6 +70,7 @@ import { enterFullscreen, exitFullscreen } from "../utils/fullscreen";
|
||||
import { ddbDiagramIsValid, jsonDiagramIsValid } from "../utils/validateSchema";
|
||||
import { dataURItoBlob } from "../utils/utils";
|
||||
import useAreas from "../hooks/useAreas";
|
||||
import useNotes from "../hooks/useNotes";
|
||||
|
||||
export default function ControlPanel({
|
||||
diagramId,
|
||||
@@ -138,7 +138,7 @@ export default function ControlPanel({
|
||||
const { types, addType, deleteType, updateType, setTypes } =
|
||||
useContext(TypeContext);
|
||||
const { notes, setNotes, updateNote, addNote, deleteNote } =
|
||||
useContext(NoteContext);
|
||||
useNotes();
|
||||
const { areas, setAreas, updateArea, addArea, deleteArea } = useAreas();
|
||||
const { undoStack, redoStack, setUndoStack, setRedoStack } = useUndoRedo();
|
||||
const { selectedElement, setSelectedElement } = useSelect();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useContext, useState } from "react";
|
||||
import { NoteContext, TabContext, StateContext } from "../pages/Editor";
|
||||
import { TabContext, StateContext } from "../pages/Editor";
|
||||
import { Action, ObjectType, noteThemes, Tab, State } from "../data/data";
|
||||
import { Input, Button, Popover, Toast } from "@douyinfe/semi-ui";
|
||||
import {
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
import useLayout from "../hooks/useLayout";
|
||||
import useUndoRedo from "../hooks/useUndoRedo";
|
||||
import useSelect from "../hooks/useSelect";
|
||||
import useNotes from "../hooks/useNotes";
|
||||
|
||||
export default function Note(props) {
|
||||
const [editField, setEditField] = useState({});
|
||||
@@ -17,7 +18,7 @@ export default function Note(props) {
|
||||
const w = 180;
|
||||
const r = 3;
|
||||
const fold = 24;
|
||||
const { updateNote, deleteNote } = useContext(NoteContext);
|
||||
const { updateNote, deleteNote } = useNotes();
|
||||
const { setUndoStack, setRedoStack } = useUndoRedo();
|
||||
const { setState } = useContext(StateContext);
|
||||
const { layout } = useLayout();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useContext, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
Empty,
|
||||
Row,
|
||||
@@ -21,12 +21,12 @@ import {
|
||||
IconSearch,
|
||||
IconCheckboxTick,
|
||||
} from "@douyinfe/semi-icons";
|
||||
import { NoteContext } from "../pages/Editor";
|
||||
import { noteThemes, Action, ObjectType } from "../data/data";
|
||||
import useUndoRedo from "../hooks/useUndoRedo";
|
||||
import useNotes from "../hooks/useNotes";
|
||||
|
||||
export default function NotesOverview() {
|
||||
const { notes, updateNote, addNote, deleteNote } = useContext(NoteContext);
|
||||
const { notes, updateNote, addNote, deleteNote } = useNotes();
|
||||
const { setUndoStack, setRedoStack } = useUndoRedo();
|
||||
const [value, setValue] = useState("");
|
||||
const [editField, setEditField] = useState({});
|
||||
|
||||
Reference in New Issue
Block a user