Implement setEditor + Add some macros
This commit is contained in:
parent
6de2c23989
commit
2ea43890f0
5 changed files with 142 additions and 13 deletions
25
src/Events/AppEvents.ts
Normal file
25
src/Events/AppEvents.ts
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue