File tree 2 files changed +18
-21
lines changed
2 files changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -22,15 +22,14 @@ class PDFHighlighter extends React.Component {
22
22
selectedText : '' ,
23
23
}
24
24
25
- componentDidMount ( ) {
26
- window . addEventListener ( 'mouseup' , this . onAfterSelection . bind ( this ) )
27
- }
28
-
29
- componentWillUnmount ( ) {
30
- window . removeEventListener ( 'mouseup' , this . onAfterSelection )
25
+ onUpdateContextMenu = partialUpdate => {
26
+ this . setState ( state => ( {
27
+ ...state ,
28
+ ...partialUpdate ,
29
+ } ) )
31
30
}
32
31
33
- onAfterSelection ( ) {
32
+ handleOnMouseUp ( ) {
34
33
const {
35
34
state : {
36
35
pdfDocument : { pdfViewer } ,
@@ -83,13 +82,6 @@ class PDFHighlighter extends React.Component {
83
82
} )
84
83
}
85
84
86
- onUpdateContextMenu = partialUpdate => {
87
- this . setState ( state => ( {
88
- ...state ,
89
- ...partialUpdate ,
90
- } ) )
91
- }
92
-
93
85
render ( ) {
94
86
const {
95
87
contextRoot,
@@ -102,6 +94,7 @@ class PDFHighlighter extends React.Component {
102
94
103
95
const children = cloneElement ( this . props . children , {
104
96
...this . props ,
97
+ handleOnMouseUp : this . handleOnMouseUp . bind ( this ) ,
105
98
} )
106
99
107
100
const contextMenu =
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ class PDFViewer extends React.PureComponent {
100
100
// when particular PDF page is not rendered
101
101
render ( ) {
102
102
const { toolbarEnabled, metadataContainerWidth } = this . state
103
- const { pdfMetadata, pdfEventBus } = this . props
103
+ const { pdfMetadata, pdfEventBus, handleOnMouseUp } = this . props
104
104
const { Metadata, pdfViewer } = this
105
105
106
106
return (
@@ -111,12 +111,16 @@ class PDFViewer extends React.PureComponent {
111
111
} }
112
112
>
113
113
{ metadataContainerWidth && < Metadata pdfMetadata = { pdfMetadata } /> }
114
- < div
115
- ref = { node => {
116
- this . viewerNode = node
117
- } }
118
- className = "pdfViewer"
119
- />
114
+ < div role = "dialog" >
115
+ < div
116
+ role = "presentation"
117
+ ref = { node => {
118
+ this . viewerNode = node
119
+ } }
120
+ className = "pdfViewer"
121
+ onMouseUp = { handleOnMouseUp }
122
+ />
123
+ </ div >
120
124
< PDFRecommender containerWidth = { metadataContainerWidth } />
121
125
{ toolbarEnabled && (
122
126
< PDFToolbar pdfViewer = { pdfViewer } pdfEventBus = { pdfEventBus } />
You can’t perform that action at this time.
0 commit comments