2022-02-13 03:15:51 +00:00

30 lines
722 B
TypeScript

import { createSlice } from "@reduxjs/toolkit";
import { RootState } from "./rootReducer";
export interface EditorState {
hotkeysEnabled: boolean;
}
const initialState: EditorState = {
hotkeysEnabled: true,
};
export const editorSlice = createSlice({
name: 'editor',
initialState: initialState,
reducers: {
disableHotkeys(state) {
state.hotkeysEnabled = false;
},
enableHotkeys(state) {
state.hotkeysEnabled = true;
},
},
});
export const hotkeysEnabled = (state: RootState): boolean => {
return state.editor.hotkeysEnabled;
};
export const { disableHotkeys, enableHotkeys } = editorSlice.actions;
export default editorSlice.reducer;