Extract IEditorState from Editor.tsx to a new file

This commit is contained in:
Siklos 2022-08-12 09:55:00 +02:00
parent 4d17249818
commit 715e2e2b2e
7 changed files with 14 additions and 11 deletions

View file

@ -2,7 +2,8 @@ import React, { useEffect, useState } from 'react';
import './App.scss';
import { MainMenu } from '../MainMenu/MainMenu';
import { ContainerModel } from '../../Interfaces/IContainerModel';
import Editor, { IEditorState } from '../Editor/Editor';
import Editor from '../Editor/Editor';
import { IEditorState } from '../../Interfaces/IEditorState';
import { LoadState } from './Load';
import { LoadEditor, NewEditor } from './MenuActions';
import { DEFAULT_CONFIG, DEFAULT_MAINCONTAINER_PROPS } from '../../utils/default';

View file

@ -1,6 +1,6 @@
import { Dispatch, SetStateAction } from 'react';
import { Revive } from '../../utils/saveload';
import { IEditorState } from '../Editor/Editor';
import { IEditorState } from '../../Interfaces/IEditorState';
export function LoadState(
editorState: IEditorState,

View file

@ -2,7 +2,7 @@ import { Dispatch, SetStateAction } from 'react';
import { IConfiguration } from '../../Interfaces/IConfiguration';
import { ContainerModel } from '../../Interfaces/IContainerModel';
import { fetchConfiguration } from '../API/api';
import { IEditorState } from '../Editor/Editor';
import { IEditorState } from "../../Interfaces/IEditorState";
import { LoadState } from './Load';
export function NewEditor(

View file

@ -15,12 +15,6 @@ interface IEditorProps {
historyCurrentStep: number
}
export interface IEditorState {
history: IHistoryState[]
historyCurrentStep: number
configuration: IConfiguration
}
export const getCurrentHistory = (history: IHistoryState[], historyCurrentStep: number): IHistoryState[] => history.slice(0, historyCurrentStep + 1);
export const getCurrentHistoryState = (history: IHistoryState[], historyCurrentStep: number): IHistoryState => history[historyCurrentStep];

View file

@ -2,7 +2,7 @@ import { IHistoryState } from '../../Interfaces/IHistoryState';
import { IConfiguration } from '../../Interfaces/IConfiguration';
import { getCircularReplacer } from '../../utils/saveload';
import { ID } from '../SVG/SVG';
import { IEditorState } from './Editor';
import { IEditorState } from '../../Interfaces/IEditorState';
export function SaveEditorAsJSON(
history: IHistoryState[],

View file

@ -0,0 +1,8 @@
import { IConfiguration } from './IConfiguration';
import { IHistoryState } from './IHistoryState';
export interface IEditorState {
history: IHistoryState[]
historyCurrentStep: number
configuration: IConfiguration
}

View file

@ -1,5 +1,5 @@
import { findContainerById, MakeIterator } from './itertools';
import { IEditorState } from '../Components/Editor/Editor';
import { IEditorState } from '../Interfaces/IEditorState';
/**
* Revive the Editor state