2017-11-09 04:00:36 +00:00
|
|
|
import { EditorState } from 'draft-js'
|
2017-11-05 19:28:55 +00:00
|
|
|
import objectAssign from 'object-assign' // Object.assign() polyfill for older browsers
|
2017-11-13 23:39:08 +00:00
|
|
|
import actions from '../actions'
|
2017-11-05 19:28:55 +00:00
|
|
|
|
|
|
|
const chapters = (state=[], action) => {
|
|
|
|
switch(action.type) {
|
|
|
|
case 'GET_CHAPTER_DATA_RECEIVED':
|
|
|
|
return action.data
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-07 03:00:32 +00:00
|
|
|
const highlightActive = (state=false, action) => {
|
|
|
|
switch(action.type) {
|
|
|
|
case 'TOGGLE_HIGHLIGHT':
|
|
|
|
return !state
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-05 19:28:55 +00:00
|
|
|
const currentChapter = (state={}, action) => {
|
|
|
|
switch(action.type) {
|
2017-11-05 23:59:18 +00:00
|
|
|
case 'GET_TEXT_DATA_RECEIVED':
|
|
|
|
return action.data
|
2017-11-05 19:28:55 +00:00
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-09 04:00:36 +00:00
|
|
|
const editorState = (state=(EditorState.createEmpty()), action) => {
|
|
|
|
switch(action.type) {
|
|
|
|
case 'UPDATE_EDITOR_STATE':
|
2017-11-13 23:39:08 +00:00
|
|
|
return action.data
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const chapterTitleInput = (state='', action) => {
|
|
|
|
switch(action.type) {
|
|
|
|
case 'UPDATE_CHAPTER_TITLE':
|
|
|
|
return action.data
|
2017-11-09 04:00:36 +00:00
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
2017-11-05 19:28:55 +00:00
|
|
|
chapters,
|
2017-11-09 04:00:36 +00:00
|
|
|
highlightActive,
|
2017-11-07 03:00:32 +00:00
|
|
|
currentChapter,
|
2017-11-13 23:39:08 +00:00
|
|
|
chapterTitleInput,
|
2017-11-09 04:00:36 +00:00
|
|
|
editorState
|
|
|
|
}
|