Add historyCurrentStep to setHistory event

This commit is contained in:
Eric NGUYEN 2022-10-13 16:18:16 +02:00
parent 749609f9a0
commit 7a81bbaec6
3 changed files with 14 additions and 10 deletions

View file

@ -12,7 +12,7 @@ export interface IEditorEvent {
func: (
root: Element | Document,
editorState: IEditorState,
setNewHistory: (newHistory: IHistoryState[]) => void,
setNewHistory: (newHistory: IHistoryState[], historyCurrentStep?: number) => void,
eventInitDict?: CustomEventInit
) => void
}
@ -50,11 +50,12 @@ function GetEditorStateAsString(root: Element | Document,
function SetHistory(root: Element | Document,
editorState: IEditorState,
setNewHistory: (newHistory: IHistoryState[]) => void,
setNewHistory: (newHistory: IHistoryState[], historyCurrentStep?: number) => void,
eventInitDict?: CustomEventInit): void {
const history: IHistoryState[] = eventInitDict?.detail;
const history: IHistoryState[] = eventInitDict?.detail.history;
const historyCurrentStep: number | undefined = eventInitDict?.detail.historyCurrentStep;
ReviveHistoryAction(history);
setNewHistory(history);
setNewHistory(history, historyCurrentStep);
const customEvent = new CustomEvent<IEditorState>('setHistory', { detail: editorState });
root.dispatchEvent(customEvent);
}