Add GetDefaultEditorState to App CustomEvents
This commit is contained in:
parent
a89b92eab8
commit
749609f9a0
2 changed files with 30 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
type IHistoryState = SVGLD.IHistoryState;
|
||||
type IEditorState = SVGLD.IEditorState;
|
||||
type IConfiguration = SVGLD.IConfiguration;
|
||||
|
||||
export class SVGLayoutDesigner extends Components.ComponentBase {
|
||||
|
||||
|
@ -178,6 +179,20 @@
|
|||
const component = this.GetAppComponent();
|
||||
component.dispatchEvent(new CustomEvent(eventType, { detail: history }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a default EditorState from a given configuration.
|
||||
* This is the same method used when loading the editor
|
||||
* for the first time after fetch the configuration from the API.
|
||||
* @param configuration History to revive
|
||||
* @param callback Callback with the revived state
|
||||
*/
|
||||
public GetDefaultEditorState(configuration: IConfiguration, callback: (state: IEditorState) => void) {
|
||||
const eventType = 'getDefaultEditorState';
|
||||
this.app.AddEventListener(eventType, callback);
|
||||
const component = this.GetAppComponent();
|
||||
component.dispatchEvent(new CustomEvent(eventType, { detail: configuration }));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue