hedgedoc/src/redux/editor/reducers.ts
mrdrogdrog c95a7e0fba
Add sync scroll button (#481)
* Add disable sync scroll button

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2020-08-25 21:36:25 +02:00

31 lines
878 B
TypeScript

import { Reducer } from 'redux'
import {
EditorConfig,
EditorConfigActions,
EditorConfigActionType,
SetEditorConfigAction,
SetEditorSyncScrollAction
} from './types'
import { EditorMode } from '../../components/editor/app-bar/editor-view-mode'
export const initialState: EditorConfig = {
editorMode: EditorMode.BOTH,
syncScroll: true
}
export const EditorConfigReducer: Reducer<EditorConfig, EditorConfigActions> = (state: EditorConfig = initialState, action: EditorConfigActions) => {
switch (action.type) {
case EditorConfigActionType.SET_EDITOR_VIEW_MODE:
return {
...state,
editorMode: (action as SetEditorConfigAction).mode
}
case EditorConfigActionType.SET_SYNC_SCROLL:
return {
...state,
syncScroll: (action as SetEditorSyncScrollAction).syncScroll
}
default:
return state
}
}