refactor[undoRedoContext]: Move undoRedoContext types to types directorie

This commit is contained in:
Igor Carvalho 2023-07-19 17:39:36 -03:00
commit bfee2ffe70
2 changed files with 27 additions and 26 deletions

View file

@ -6,32 +6,9 @@ import {
useEffect, useEffect,
useState, useState,
} from "react"; } from "react";
import { Edge, Node, useReactFlow } from "reactflow"; import { useReactFlow } from "reactflow";
import { TabsContext } from "./tabsContext"; import { TabsContext } from "./tabsContext";
import { undoRedoContextType, UseUndoRedoOptions , UseUndoRedo, HistoryItem } from "../types/typesContext";
type undoRedoContextType = {
undo: () => void;
redo: () => void;
takeSnapshot: () => void;
};
type UseUndoRedoOptions = {
maxHistorySize: number;
enableShortcuts: boolean;
};
type UseUndoRedo = (options?: UseUndoRedoOptions) => {
undo: () => void;
redo: () => void;
takeSnapshot: () => void;
canUndo: boolean;
canRedo: boolean;
};
type HistoryItem = {
nodes: Node[];
edges: Edge[];
};
const initialValue = { const initialValue = {
undo: () => {}, undo: () => {},

View file

@ -1,4 +1,4 @@
import { ReactFlowInstance } from "reactflow"; import { ReactFlowInstance, Edge, Node } from "reactflow";
import { APIClassType } from "../api"; import { APIClassType } from "../api";
import { AlertItemType } from "../alerts"; import { AlertItemType } from "../alerts";
@ -72,3 +72,27 @@ export type locationContextType = {
extraComponent: any; extraComponent: any;
setExtraComponent: (newState: any) => void; setExtraComponent: (newState: any) => void;
}; };
export type undoRedoContextType = {
undo: () => void;
redo: () => void;
takeSnapshot: () => void;
};
export type UseUndoRedoOptions = {
maxHistorySize: number;
enableShortcuts: boolean;
};
export type UseUndoRedo = (options?: UseUndoRedoOptions) => {
undo: () => void;
redo: () => void;
takeSnapshot: () => void;
canUndo: boolean;
canRedo: boolean;
};
export type HistoryItem = {
nodes: Node[];
edges: Edge[];
};