blob: 882547980395784e3d58c5ea1fb2663935952f10 (
plain)
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
|
import React, { Component } from 'react'
import { ROMAN_NUMERALS } from 'app/constants'
export const Paragraph = ({ paragraph, currentParagraph, currentAnnotation, onAnnotationClick, onDoubleClick }) => {
let className = paragraph.type
if (className !== 'paragraph') className += ' paragraph'
if (currentParagraph) className += ' current'
return (
<div
className={className}
onDoubleClick={e => onDoubleClick(e, paragraph)}
>
{paragraph.annotations.map(annotation => (
<span
key={annotation.id}
className={annotation.id === currentAnnotation ? 'current' : ''}
onClick={e => onAnnotationClick(e, paragraph, annotation)}
dangerouslySetInnerHTML={{ __html: ' ' + annotation.text + ' ' }}
/>
))}
</div>
)
}
export const ParagraphHeading = ({ paragraph, currentParagraph, currentAnnotation, onAnnotationClick, onDoubleClick }) => {
let className = currentParagraph ? 'header current' : 'header'
const text = paragraph.annotations.map(annotation => annotation.text).join(' ')
return (
<div
className={className}
onDoubleClick={e => onDoubleClick(e, paragraph)}
>
<span>{ROMAN_NUMERALS[paragraph.sectionIndex]}{'. '}{text}</span>
</div>
)
}
|