diff --git a/src/components/presenter.js b/src/components/presenter.js index 6ef724ab9..5d20310f5 100644 --- a/src/components/presenter.js +++ b/src/components/presenter.js @@ -16,9 +16,33 @@ const startTime = function startTime(date) { @Radium export default class Presenter extends Component { - constructor() { + static childContextTypes = { + updateNotes: PropTypes.func + }; + + getChildContext() { + return { + updateNotes: this.updateNotes.bind(this) + }; + } + + getCurrentSlide() { + return this.context.store.getState().route.slide; + } + + updateNotes(newNotes) { + var notes = Object.assign({}, this.state.notes); + notes[this.getCurrentSlide()] = newNotes; + + this.setState({ + notes: notes + }); + } + + constructor(props) { super(); this.state = { + notes: {}, time: startTime(new Date()) }; } @@ -80,12 +104,22 @@ export default class Presenter extends Component { }) :

END

; } _renderNotes() { - const child = this.props.slides[this.props.slide]; - if (!child.props.notes) { return false; } - if (typeof child.props.notes === "string") { - return
; + var notes; + var currentSlide = this.getCurrentSlide(); + + if (this.state.notes[currentSlide]) { + notes = this.state.notes[currentSlide]; + } else { + const child = this.props.slides[this.props.slide]; + notes = child.props.notes; + } + + if (!notes) { return false; } + + if (typeof notes === "string") { + return
; } - return
{child.props.notes}
; + return
{notes}
; } render() { const styles = { @@ -198,5 +232,6 @@ Presenter.propTypes = { }; Presenter.contextTypes = { - styles: PropTypes.object + styles: PropTypes.object, + store: PropTypes.object.isRequired, };