1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
import React, { Component } from 'react'
import { Route } from 'react-router-dom'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import actions from 'app/actions'
import ParagraphForm from '../components/paragraph.form'
import ParagraphList from '../components/paragraph.list'
import { paragraphElementLookup } from '../components/paragraphTypes'
class ParagraphEditor extends Component {
state = {
selectedParagraph: null,
selectedParagraphOffset: 0,
}
constructor(props) {
super(props)
this.handleAnnotationClick = this.handleAnnotationClick.bind(this)
this.handleParagraphDoubleClick = this.handleParagraphDoubleClick.bind(this)
this.handleCloseParagraphForm = this.handleCloseParagraphForm.bind(this)
this.updateSelectedParagraph = this.updateSelectedParagraph.bind(this)
}
handleAnnotationClick(e, paragraph, annotation){
actions.audio.seek(annotation.start_ts)
}
handleParagraphDoubleClick(e, paragraph) {
let paragraphNode = e.target
if (!paragraphNode.classList.contains('paragraph')) {
paragraphNode = paragraphNode.parentNode
}
this.setState({
selectedParagraph: { ...paragraph },
selectedParagraphOffset: paragraphNode.offsetTop
})
}
updateSelectedParagraph(selectedParagraph) {
this.setState({ selectedParagraph })
}
handleCloseParagraphForm() {
this.setState({ selectedParagraph: null })
}
render() {
// const { media } = this.props
const { paragraphs, selectedParagraph, selectedParagraphOffset } = this.state
return (
<div className='paragraphs'>
<div className='content'>
<ParagraphList
paragraphElementLookup={paragraphElementLookup}
selectedParagraph={selectedParagraph}
onAnnotationClick={this.handleAnnotationClick}
onParagraphDoubleClick={this.handleParagraphDoubleClick}
/>
{selectedParagraph &&
<ParagraphForm
paragraph={selectedParagraph}
onUpdate={this.updateSelectedParagraph}
onClose={this.handleCloseParagraphForm}
y={selectedParagraphOffset}
/>
}
</div>
</div>
)
}
}
const mapStateToProps = state => ({
// paragraph: state.paragraph.index,
// annotation: state.annotation.index,
// audio: state.audio,
// media: state.media.index,
})
const mapDispatchToProps = dispatch => ({
})
export default connect(mapStateToProps, mapDispatchToProps)(ParagraphEditor)
|