import {
  SETPERSONALTEXTMODEVALUE,
  REPERSONTEXTDATA,
  CLEARPERSONTEXTDATA,
} from '../types/personalHistory';
import { setTextModeValue, rePersonalData } from '../actions/personalHistory';
import config from '@config/index';
const block = Object.assign(JSON.parse(config.textLabel), { full: true });//空白时保留一个自由文本标签
const initState = {
  data: [block],
  isEmpty: true,
  saveText: [],
  deledTags: {},
  focusIndex: '',
  editClear: true
};

export default function (state = initState, action) {//console.log(state)
  const res = Object.assign({}, state);
  switch (action.type) {
    case SETPERSONALTEXTMODEVALUE:
      return setTextModeValue(state, action);
    case REPERSONTEXTDATA:
      return rePersonalData(state, action);
    case CLEARPERSONTEXTDATA:
      res.saveText = [];
      return res;
    default:
      return res;
  }
}