Skip to content
Snippets Groups Projects
Commit c3d8d4e5 authored by john's avatar john
Browse files

more cleanup

parent 9d86bfde
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,12 @@ class Editor extends ProseEditor {
return el
}
// TODO -- use this to insert read-only mode alert
_renderToolbar ($$) {
const toolbar = super._renderToolbar($$)
return toolbar
}
_renderEditor ($$) {
const configurator = this.props.configurator
const editing = this.props.disabled ? 'selection' : 'full'
......
......@@ -35,7 +35,6 @@ export default class SimpleEditor extends React.Component {
componentWillMount () {
const { fragment } = this.props
if (fragment) {
console.log('fragment? yes!', fragment)
this._checkRights()
this._acquireLock()
}
......@@ -138,33 +137,39 @@ export default class SimpleEditor extends React.Component {
}
componentDidMount () {
const { onSave } = this.props
const el = ReactDOM.findDOMNode(this)
const { fragment } = this.props
const session = this.createSession()
const documentSession = session.documentSession
const configurator = session.configurator
const { book, fileUpload, fragment, history, onSave, update, user } = this.props
const { configurator, documentSession } = this.createSession()
if (!fragment) return
const containerId = 'body'
// TODO -- delete
const trackChanges = fragment.trackChanges
const updateTrackChangesStatus = this.updateTrackChangesStatus
const disabled = !this.state.canEdit
this.setState({
config: configurator.config
})
Editor.mount({
book: this.props.book,
configurator: configurator,
containerId: 'body',
disabled: !this.state.canEdit, // set to true read only mode
documentSession: documentSession,
fileUpload: this.props.fileUpload,
fragment: this.props.fragment,
history: this.props.history,
onSave: onSave,
trackChanges: this.props.fragment.trackChanges,
update: this.props.update,
updateTrackChangesStatus: this.updateTrackChangesStatus,
user: this.props.user
book,
configurator,
containerId,
disabled,
documentSession,
fileUpload,
fragment,
history,
onSave,
trackChanges,
update,
updateTrackChangesStatus,
user
}, el)
window.addEventListener('beforeunload', this._releaseLock)
......
......@@ -11,9 +11,9 @@ export class SimpleEditorWrapper extends React.Component {
constructor (props) {
super(props)
this.fileUpload = this.fileUpload.bind(this)
this.save = this.save.bind(this)
this.update = this.update.bind(this)
this.fileUpload = this.fileUpload.bind(this)
}
componentWillMount () {
......@@ -27,12 +27,20 @@ export class SimpleEditorWrapper extends React.Component {
user.roles = this.getRoles()
}
save (source, callback) {
const { book, fragment } = this.props
const { updateFragment } = this.props.actions
render () {
const { book, fragment, history, user } = this.props
fragment.source = source
updateFragment(book, fragment)
return (
<SimpleEditor
book={book}
fileUpload={this.fileUpload}
fragment={fragment}
history={history}
onSave={this.save}
update={this.update}
user={user}
/>
)
}
fileUpload (file) {
......@@ -40,12 +48,6 @@ export class SimpleEditorWrapper extends React.Component {
return fileUpload(file)
}
update (newChapter) {
const { book } = this.props
const { updateFragment } = this.props.actions
updateFragment(book, newChapter)
}
getRoles () {
const { user, book } = this.props
......@@ -67,20 +69,18 @@ export class SimpleEditorWrapper extends React.Component {
return roles
}
render () {
const { book, fragment, history, user } = this.props
save (source, callback) {
const { book, fragment } = this.props
const { updateFragment } = this.props.actions
return (
<SimpleEditor
book={book}
fileUpload={this.fileUpload}
fragment={fragment}
history={history}
onSave={this.save}
update={this.update}
user={user}
/>
)
fragment.source = source
updateFragment(book, fragment)
}
update (newChapter) {
const { book } = this.props
const { updateFragment } = this.props.actions
updateFragment(book, newChapter)
}
}
......@@ -89,13 +89,13 @@ SimpleEditorWrapper.propTypes = {
book: React.PropTypes.object.isRequired,
fragment: React.PropTypes.object,
history: React.PropTypes.object.isRequired,
user: React.PropTypes.object.isRequired,
update: React.PropTypes.func
update: React.PropTypes.func,
user: React.PropTypes.object.isRequired
}
function mapStateToProps (state, ownProps) {
const mapStateToProps = (state, ownProps) => {
const bookId = ownProps.params.bookId
const book = find(state.collections, function (c) {
const book = find(state.collections, (c) => {
return c.id === bookId
})
......@@ -107,7 +107,7 @@ function mapStateToProps (state, ownProps) {
return { fragment, book, user }
}
function mapDispatchToProps (dispatch) {
const mapDispatchToProps = (dispatch) => {
return {
actions: bindActionCreators(Actions, dispatch)
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment