Allow LoadEditor through external resource
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4127a9a6eb
commit
893876ddaa
1 changed files with 28 additions and 8 deletions
24
src/App.tsx
24
src/App.tsx
|
@ -40,6 +40,22 @@ export class App extends React.Component<IAppProps> {
|
|||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
const state = urlParams.get('state');
|
||||
|
||||
if (state === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(state)
|
||||
.then((response) => response.json())
|
||||
.then((data: IEditorState) => {
|
||||
this.LoadState(data);
|
||||
});
|
||||
}
|
||||
|
||||
public NewEditor() {
|
||||
// Fetch the configuration from the API
|
||||
fetchConfiguration().then((configuration: Configuration) => {
|
||||
|
@ -86,6 +102,12 @@ export class App extends React.Component<IAppProps> {
|
|||
const result = reader.result as string;
|
||||
const editorState: IEditorState = JSON.parse(result);
|
||||
|
||||
this.LoadState(editorState);
|
||||
});
|
||||
reader.readAsText(file);
|
||||
}
|
||||
|
||||
private LoadState(editorState: IEditorState) {
|
||||
Revive(editorState);
|
||||
|
||||
this.setState({
|
||||
|
@ -94,8 +116,6 @@ export class App extends React.Component<IAppProps> {
|
|||
historyCurrentStep: editorState.historyCurrentStep,
|
||||
isLoaded: true
|
||||
} as IAppState);
|
||||
});
|
||||
reader.readAsText(file);
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue