Remove deprecated EditorEvents

This commit is contained in:
Eric NGUYEN 2023-02-24 14:46:24 +01:00
parent c725b107a4
commit 4fcf600c88
2 changed files with 5 additions and 121 deletions

View file

@ -364,6 +364,7 @@
* @param index Position to insert the container * @param index Position to insert the container
* @param type Container type to create * @param type Container type to create
* @param callback * @param callback
* @deprecated Do not use this function, use AddContainer instead
*/ */
public AddContainerToSelectedContainer(index: number, type: string, callback?: (state: IEditorState) => void) { public AddContainerToSelectedContainer(index: number, type: string, callback?: (state: IEditorState) => void) {
const eventType = 'addContainerToSelectedContainer'; const eventType = 'addContainerToSelectedContainer';
@ -396,6 +397,7 @@
* Append a new container in the current selected container * Append a new container in the current selected container
* @param type Container type to create * @param type Container type to create
* @param callback * @param callback
* @deprecated Do not use this function, use AppendContainer instead
*/ */
public AppendContainerToSelectedContainer(type: string, callback?: (state: IEditorState) => void) { public AppendContainerToSelectedContainer(type: string, callback?: (state: IEditorState) => void) {
const eventType = 'appendContainerToSelectedContainer'; const eventType = 'appendContainerToSelectedContainer';
@ -410,6 +412,7 @@
* Select a container by id * Select a container by id
* @param containerId Container's id to select * @param containerId Container's id to select
* @param callback * @param callback
* @deprecated Do not use this function
*/ */
public SelectContainer(containerId: string, callback?: (state: IEditorState) => void) { public SelectContainer(containerId: string, callback?: (state: IEditorState) => void) {
const eventType = 'selectContainer'; const eventType = 'selectContainer';
@ -453,6 +456,7 @@
* Select a symbol by id * Select a symbol by id
* @param symbolId Symbol's id to select * @param symbolId Symbol's id to select
* @param callback * @param callback
* @deprecated Do not use this function
*/ */
public SelectSymbol(symbolId: string, callback?: (state: IEditorState) => void) { public SelectSymbol(symbolId: string, callback?: (state: IEditorState) => void) {
const eventType = 'selectSymbol'; const eventType = 'selectSymbol';

View file

@ -1,7 +1,6 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { import {
AddContainer as AddContainerAction, AddContainer as AddContainerAction
AddContainerToSelectedContainer as AddContainerToSelectedContainerAction
} from '../Components/Editor/Actions/AddContainer'; } from '../Components/Editor/Actions/AddContainer';
import { import {
DeleteContainer as DeleteContainerAction DeleteContainer as DeleteContainerAction
@ -35,13 +34,9 @@ export const events: IEditorEvent[] = [
{ name: 'getCurrentHistoryState', func: GetCurrentHistoryState }, { name: 'getCurrentHistoryState', func: GetCurrentHistoryState },
{ name: 'appendNewState', func: AppendNewState }, { name: 'appendNewState', func: AppendNewState },
{ name: 'addContainer', func: AddContainer }, { name: 'addContainer', func: AddContainer },
// { name: 'addContainerToSelectedContainer', func: AddContainerToSelectedContainer },
{ name: 'appendContainer', func: AppendContainer }, { name: 'appendContainer', func: AppendContainer },
// { name: 'appendContainerToSelectedContainer', func: AppendContainerToSelectedContainer },
// { name: 'selectContainer', func: SelectContainer },
{ name: 'deleteContainer', func: DeleteContainer }, { name: 'deleteContainer', func: DeleteContainer },
{ name: 'addSymbol', func: AddSymbol }, { name: 'addSymbol', func: AddSymbol },
// { name: 'selectSymbol', func: SelectSymbol },
{ name: 'deleteSymbol', func: DeleteSymbol } { name: 'deleteSymbol', func: DeleteSymbol }
]; ];
@ -201,37 +196,6 @@ function AddContainer({
root.dispatchEvent(customEvent); root.dispatchEvent(customEvent);
} }
// function AddContainerToSelectedContainer({
// root,
// editorState,
// setNewHistory,
// eventInitDict
// }: IEditorEventParams): void {
// const {
// index,
// type
// } = eventInitDict?.detail;
// const history = GetCurrentHistory(editorState.history, editorState.historyCurrentStep);
// const currentState = history[editorState.historyCurrentStep];
// const newHistory = AddContainerAction(
// index,
// type,
// currentState.selectedContainerId,
// editorState.configuration,
// history,
// editorState.historyCurrentStep
// );
// setNewHistory(newHistory);
// const customEvent = new CustomEvent<IHistoryState>(
// 'addContainerToSelectedContainer',
// { detail: structuredClone(editorState.history[editorState.historyCurrentStep]) }
// );
// root.dispatchEvent(customEvent);
// }
function AppendContainer({ function AppendContainer({
root, root,
editorState, editorState,
@ -265,64 +229,6 @@ function AppendContainer({
root.dispatchEvent(customEvent); root.dispatchEvent(customEvent);
} }
// function AppendContainerToSelectedContainer({
// root,
// editorState,
// setNewHistory,
// eventInitDict
// }: IEditorEventParams): void {
// const {
// type
// } = eventInitDict?.detail;
// const history = GetCurrentHistory(editorState.history, editorState.historyCurrentStep);
// const currentState = history[editorState.historyCurrentStep];
// const selected = FindContainerById(currentState.containers, currentState.selectedContainerId);
// if (selected !== null && selected !== undefined) {
// setNewHistory(AddContainerToSelectedContainerAction(
// type,
// selected,
// editorState.configuration,
// history,
// editorState.historyCurrentStep
// ));
// }
// const customEvent = new CustomEvent<IHistoryState>(
// 'appendContainerToSelectedContainer',
// { detail: structuredClone(editorState.history[editorState.historyCurrentStep]) }
// );
// root.dispatchEvent(customEvent);
// }
// function SelectContainer({
// root,
// editorState,
// setNewHistory,
// eventInitDict
// }: IEditorEventParams): void {
// const {
// containerId
// } = eventInitDict?.detail;
// const history = GetCurrentHistory(editorState.history, editorState.historyCurrentStep);
// const newHistory = SelectContainerAction(
// containerId,
// history,
// editorState.historyCurrentStep
// );
// setNewHistory(newHistory);
// const customEvent = new CustomEvent<IHistoryState>(
// 'selectContainer',
// { detail: structuredClone(editorState.history[editorState.historyCurrentStep]) }
// );
// root.dispatchEvent(customEvent);
// }
function DeleteContainer({ function DeleteContainer({
root, root,
editorState, editorState,
@ -376,32 +282,6 @@ function AddSymbol({
root.dispatchEvent(customEvent); root.dispatchEvent(customEvent);
} }
// function SelectSymbol({
// root,
// editorState,
// setNewHistory,
// eventInitDict
// }: IEditorEventParams): void {
// const {
// symbolId
// } = eventInitDict?.detail;
// const history = GetCurrentHistory(editorState.history, editorState.historyCurrentStep);
// const newHistory = SelectSymbolAction(
// symbolId,
// history,
// editorState.historyCurrentStep
// );
// setNewHistory(newHistory);
// const customEvent = new CustomEvent<IHistoryState>(
// 'SelectSymbol',
// { detail: structuredClone(editorState.history[editorState.historyCurrentStep]) }
// );
// root.dispatchEvent(customEvent);
// }
function DeleteSymbol({ function DeleteSymbol({
root, root,
editorState, editorState,