Move ReviveEditor and ReviveHistory to App

This commit is contained in:
Eric NGUYEN 2022-10-13 11:56:41 +02:00
parent 8962132a4d
commit fb6bc1289d
3 changed files with 55 additions and 53 deletions

View file

@ -5,7 +5,7 @@ import { GetCurrentHistory } from '../Components/Editor/Editor';
import { IEditorState } from '../Interfaces/IEditorState';
import { IHistoryState } from '../Interfaces/IHistoryState';
import { FindContainerById } from '../utils/itertools';
import { GetCircularReplacer, Revive, ReviveHistory as ReviveHistoryAction } from '../utils/saveload';
import { GetCircularReplacer, ReviveHistory as ReviveHistoryAction } from '../utils/saveload';
export interface IEditorEvent {
name: string
@ -21,8 +21,6 @@ export const events: IEditorEvent[] = [
{ name: 'getEditorState', func: GetEditorState },
{ name: 'getEditorStateAsString', func: GetEditorStateAsString },
{ name: 'setHistory', func: SetHistory },
{ name: 'reviveEditorState', func: ReviveEditorState },
{ name: 'reviveHistory', func: ReviveHistory },
{ name: 'getCurrentHistoryState', func: GetCurrentHistoryState },
{ name: 'appendNewState', func: AppendNewState },
{ name: 'addContainer', func: AddContainer },
@ -61,28 +59,6 @@ function SetHistory(root: Element | Document,
root.dispatchEvent(customEvent);
}
function ReviveEditorState(
root: Element | Document,
editorState: IEditorState,
setNewHistory: (newHistory: IHistoryState[]) => void,
eventInitDict?: CustomEventInit): void {
const anEditorState: IEditorState = eventInitDict?.detail;
Revive(anEditorState);
const customEvent = new CustomEvent<IEditorState>('reviveEditorState', { detail: anEditorState });
root.dispatchEvent(customEvent);
}
function ReviveHistory(
root: Element | Document,
editorState: IEditorState,
setNewHistory: (newHistory: IHistoryState[]) => void,
eventInitDict?: CustomEventInit): void {
const history: IHistoryState[] = eventInitDict?.detail;
ReviveHistoryAction(history);
const customEvent = new CustomEvent<IHistoryState[]>('reviveHistory', { detail: history });
root.dispatchEvent(customEvent);
}
function GetCurrentHistoryState(root: Element | Document,
editorState: IEditorState): void {
const customEvent = new CustomEvent<IHistoryState>(