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

View file

@ -19,7 +19,7 @@ export interface IEditorEvent {
export const events: IEditorEvent[] = [
{ name: 'getEditorState', func: GetEditorState },
{ name: 'setEditorState', func: SetEditorState },
{ name: 'setHistory', func: SetHistory },
{ name: 'reviveEditorState', func: ReviveEditorState },
{ name: 'reviveHistory', func: ReviveHistory },
{ name: 'getCurrentHistoryState', func: GetCurrentHistoryState },
@ -41,15 +41,14 @@ function GetEditorState(root: Element | Document,
root.dispatchEvent(customEvent);
}
// TODO: In the near future, implement a real SetEditorState which also change IConfiguration
function SetEditorState(root: Element | Document,
function SetHistory(root: Element | Document,
editorState: IEditorState,
setNewHistory: (newHistory: IHistoryState[]) => void,
eventInitDict?: CustomEventInit): void {
const history: IHistoryState[] = eventInitDict?.detail;
ReviveHistoryAction(history);
setNewHistory(history);
const customEvent = new CustomEvent<IEditorState>('setEditorState', { detail: editorState });
const customEvent = new CustomEvent<IEditorState>('setHistory', { detail: editorState });
root.dispatchEvent(customEvent);
}