import React, { Component, PropTypes } from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import SplitPane from 'react-split-pane'; import Button from 'react-toolbox/lib/button'; import { ScrollSync, ScrollSyncPane } from '../ScrollSync'; import ControlPane from '../ControlPanel/ControlPane'; import PreviewPane from '../PreviewPane/PreviewPane'; import Toolbar from './EntryEditorToolbar'; import styles from './EntryEditor.css'; const PREVIEW_HIDE = 'cms.preview-state'; class EntryEditor extends Component { state = { showEventBlocker: false, previewOpen: localStorage.getItem(PREVIEW_HIDE) === "false", }; handleSplitPaneDragStart = () => { this.setState({ showEventBlocker: true }); }; handleSplitPaneDragFinished = () => { this.setState({ showEventBlocker: false }); }; handleOnPersist = () => { this.controlPaneRef.validate(); this.props.onPersist(); }; handleTogglePreview = () => { const { previewOpen } = this.state; const newPreviewState = !previewOpen ? "false" : "true"; this.setState( { previewOpen: !previewOpen }, localStorage.setItem(PREVIEW_HIDE, newPreviewState) ); }; render() { const { collection, entry, fields, fieldsMetaData, fieldsErrors, getAsset, onChange, onValidate, onAddAsset, onRemoveAsset, onCancelEdit, } = this.props; const { previewOpen } = this.state; const controlClassName = `${ styles.controlPane } ${ this.state.showEventBlocker && styles.blocker }`; const previewClassName = `${ styles.previewPane } ${ this.state.showEventBlocker && styles.blocker }`; const editor = (