aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-07-27 16:49:07 -0400
committeryipstanley <stanley_yip@brown.edu>2019-07-27 16:49:07 -0400
commitd53ad748d90ca1c863a7ef52d0835573ce967a54 (patch)
tree40425d9b27546bac7260be752857a02f320b2671 /src/client/views/pdf
parente189378e5ce01eedd1373172fbd8d8dabf2ad197 (diff)
init
Diffstat (limited to 'src/client/views/pdf')
-rw-r--r--src/client/views/pdf/Page.tsx11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/client/views/pdf/Page.tsx b/src/client/views/pdf/Page.tsx
index c9d442fe5..c6bdb2af6 100644
--- a/src/client/views/pdf/Page.tsx
+++ b/src/client/views/pdf/Page.tsx
@@ -357,7 +357,8 @@ export default class Page extends React.Component<IPageProps> {
else {
let sel = window.getSelection();
if (sel && sel.type === "Range") {
- this.createTextAnnotation(sel);
+ let selRange = sel.getRangeAt(0);
+ this.createTextAnnotation(sel, selRange);
PDFMenu.Instance.jumpTo(e.clientX, e.clientY);
}
}
@@ -375,8 +376,8 @@ export default class Page extends React.Component<IPageProps> {
}
@action
- createTextAnnotation = (sel: Selection) => {
- let clientRects = sel.getRangeAt(0).getClientRects();
+ createTextAnnotation = (sel: Selection, selRange: Range) => {
+ let clientRects = selRange.getClientRects();
if (this._textLayer.current) {
let boundingRect = this._textLayer.current.getBoundingClientRect();
for (let i = 0; i < clientRects.length; i++) {
@@ -393,6 +394,10 @@ export default class Page extends React.Component<IPageProps> {
}
}
}
+ let text = selRange.extractContents().textContent;
+ if (text) {
+ this.props.parent.selectionText = text;
+ }
// clear selection
if (sel.empty) { // Chrome
sel.empty();