Skip to content

Commit f5b7d22

Browse files
committed
Fix: workspace reset
1 parent 904c7c4 commit f5b7d22

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/hooks/events/workspace-load.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const useWorkspaceLoad = (props: ISTKProps) => {
1414
if (props.data) {
1515
store.dispatch(sync(props.data));
1616
} else {
17-
store.dispatch(initializeElements());
17+
if (!props.options?.blank) {
18+
store.dispatch(initializeElements());
19+
}
1820
}
1921
props.events?.onWorkspaceLoad?.();
2022
}, [props.data]);

src/store/reducers/editor/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ export const slice = createSlice({
9191
resetWorkspace: (state) => {
9292
state.initialized = false;
9393
state.dataSynced = false;
94+
Object.keys(initialState).forEach((key) => {
95+
state[key] = initialState[key];
96+
});
9497
},
9598
setCursor: (state, action) => {
9699
state.cursor = action.payload;

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export interface ISTKProps {
8686
maxImageSize?: number;
8787
/** Overrides the default input placeholder at the top left corner of the screen */
8888
locationInputPlaceholder?: string;
89+
/** Loads a blank workspace */
90+
blank?: boolean;
8991
};
9092
plugins?: IPlugins;
9193
}

0 commit comments

Comments
 (0)