Skip to content

Commit

Permalink
Fix: workspace reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed May 18, 2024
1 parent 904c7c4 commit f5b7d22
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/hooks/events/workspace-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const useWorkspaceLoad = (props: ISTKProps) => {
if (props.data) {
store.dispatch(sync(props.data));
} else {
store.dispatch(initializeElements());
if (!props.options?.blank) {
store.dispatch(initializeElements());
}
}
props.events?.onWorkspaceLoad?.();
}, [props.data]);
Expand Down
3 changes: 3 additions & 0 deletions src/store/reducers/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export const slice = createSlice({
resetWorkspace: (state) => {
state.initialized = false;
state.dataSynced = false;
Object.keys(initialState).forEach((key) => {
state[key] = initialState[key];
});
},
setCursor: (state, action) => {
state.cursor = action.payload;
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export interface ISTKProps {
maxImageSize?: number;
/** Overrides the default input placeholder at the top left corner of the screen */
locationInputPlaceholder?: string;
/** Loads a blank workspace */
blank?: boolean;
};
plugins?: IPlugins;
}

0 comments on commit f5b7d22

Please sign in to comment.