Implement setEditor + Add some macros

This commit is contained in:
Eric NGUYEN 2022-09-23 14:55:57 +02:00
parent 6de2c23989
commit 2ea43890f0
5 changed files with 142 additions and 13 deletions

25
src/Events/AppEvents.ts Normal file
View file

@ -0,0 +1,25 @@
import { IEditorState } from '../Interfaces/IEditorState';
export interface IAppEvent {
name: string
func: (
root: Element | Document,
setEditor: (newState: IEditorState) => void,
eventInitDict?: CustomEventInit
) => void
}
export const events: IAppEvent[] = [
{ name: 'setEditor', func: SetEditor }
];
function SetEditor(
root: Element | Document,
setEditor: (newState: IEditorState) => void,
eventInitDict?: CustomEventInit
): void {
const editor: IEditorState = eventInitDict?.detail;
setEditor(editor);
const customEvent = new CustomEvent<IEditorState>('setEditor', { detail: editor });
root.dispatchEvent(customEvent);
}