Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
59b9508b
Commit
59b9508b
authored
Dec 09, 2014
by
Randall Leeds
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1775 from hypothesis/update-pdfjs-support
Update PDF plugin
parents
de6e7f4a
ad1a4b16
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
41 deletions
+66
-41
annotator.pdf.js
h/static/scripts/vendor/annotator.pdf.js
+66
-41
No files found.
h/static/scripts/vendor/annotator.pdf.js
View file @
59b9508b
// Generated by CoffeeScript 1.6.3
/*
** Annotator 1.2.6-dev-
95b7a09
** Annotator 1.2.6-dev-
18d8f72
** https://github.com/okfn/annotator/
**
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2014-1
1-26 22:32:31
Z
** Built at: 2014-1
2-08 17:27:52
Z
*/
...
...
@@ -18,44 +18,75 @@
// Generated by CoffeeScript 1.6.3
(
function
()
{
var
_ref
,
var
PDFTextMapper
,
_ref
,
__bind
=
function
(
fn
,
me
){
return
function
(){
return
fn
.
apply
(
me
,
arguments
);
};
},
__hasProp
=
{}.
hasOwnProperty
,
__extends
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
__hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
window
.
PDFTextMapper
=
(
function
(
_super
)
{
PDFTextMapper
=
(
function
(
_super
)
{
__extends
(
PDFTextMapper
,
_super
);
PDFTextMapper
.
isPDFDocument
=
function
()
{
return
(
typeof
PDFView
!==
"undefined"
&&
PDFView
!==
null
)
||
(
typeof
PDFViewerApplication
!==
"undefined"
&&
PDFViewerApplication
!==
null
);
};
PDFTextMapper
.
applicable
=
function
()
{
return
t
ypeof
PDFView
!==
"undefined"
&&
PDFView
!==
null
;
return
t
his
.
isPDFDocument
()
;
};
PDFTextMapper
.
prototype
.
requiresSmartStringPadding
=
true
;
PDFTextMapper
.
prototype
.
getPageCount
=
function
()
{
return
PDFView
.
pages
.
length
;
return
this
.
_viewer
.
pages
.
length
;
};
PDFTextMapper
.
prototype
.
getPageIndex
=
function
()
{
return
PDFView
.
page
-
1
;
return
this
.
_app
.
page
-
1
;
};
PDFTextMapper
.
prototype
.
setPageIndex
=
function
(
index
)
{
return
PDFView
.
page
=
index
+
1
;
return
this
.
_app
.
page
=
index
+
1
;
};
PDFTextMapper
.
prototype
.
_isPageRendered
=
function
(
index
)
{
var
_ref
,
_ref1
;
return
(
_ref
=
PDFView
.
pages
[
index
])
!=
null
?
(
_ref1
=
_ref
.
textLayer
)
!=
null
?
_ref1
.
renderingDone
:
void
0
:
void
0
;
return
(
_ref
=
this
.
_viewer
.
pages
[
index
])
!=
null
?
(
_ref1
=
_ref
.
textLayer
)
!=
null
?
_ref1
.
renderingDone
:
void
0
:
void
0
;
};
PDFTextMapper
.
prototype
.
getRootNodeForPage
=
function
(
index
)
{
return
PDFView
.
pages
[
index
].
textLayer
.
textLayerDiv
;
return
this
.
_viewer
.
pages
[
index
].
textLayer
.
textLayerDiv
;
};
function
PDFTextMapper
()
{
this
.
_finishScan
=
__bind
(
this
.
_finishScan
,
this
);
this
.
_parseExtractedText
=
__bind
(
this
.
_parseExtractedText
,
this
);
var
_ref
,
_this
=
this
;
if
(
typeof
PDFViewerApplication
!==
"undefined"
&&
PDFViewerApplication
!==
null
)
{
this
.
_app
=
PDFViewerApplication
;
this
.
_viewer
=
this
.
_app
.
pdfViewer
;
this
.
_tryExtractPage
=
function
(
index
)
{
return
_this
.
_viewer
.
getPageTextContent
(
index
);
};
}
else
{
this
.
_app
=
this
.
_viewer
=
PDFView
;
this
.
_finder
=
(
_ref
=
this
.
_app
.
findController
)
!=
null
?
_ref
:
PDFFindController
;
this
.
_tryExtractPage
=
function
(
index
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
tryIt
;
tryIt
=
function
()
{
var
page
;
page
=
_this
.
_finder
.
pdfPageSource
.
pages
[
index
];
if
((
page
!=
null
?
page
.
pdfPage
:
void
0
)
!=
null
)
{
return
page
.
getTextContent
().
then
(
resolve
);
}
else
{
return
setTimeout
(
tryIt
,
100
);
}
};
return
tryIt
();
});
};
}
this
.
setEvents
();
}
...
...
@@ -93,7 +124,7 @@
}
}
});
return
$
(
PDFView
.
container
).
on
(
'scroll'
,
function
()
{
return
$
(
this
.
_viewer
.
container
).
on
(
'scroll'
,
function
()
{
return
_this
.
_onScroll
();
});
};
...
...
@@ -104,12 +135,11 @@
return
text
.
replace
(
this
.
_extractionPattern
,
" "
);
};
PDFTextMapper
.
prototype
.
_
waitForInit
=
function
()
{
PDFTextMapper
.
prototype
.
waitForInit
=
function
()
{
var
tryIt
,
_this
=
this
;
tryIt
=
function
(
resolve
)
{
var
_this
=
this
;
if
(
PDFView
.
documentFingerprint
&&
PDFView
.
documentInfo
)
{
if
(
_this
.
_app
.
documentFingerprint
&&
_this
.
_app
.
documentInfo
)
{
return
resolve
();
}
else
{
return
setTimeout
((
function
()
{
...
...
@@ -118,7 +148,7 @@
}
};
return
new
Promise
(
function
(
resolve
,
reject
)
{
if
(
typeof
PDFView
!==
"undefined"
&&
PDFView
!==
null
)
{
if
(
PDFTextMapper
.
applicable
()
)
{
return
tryIt
(
resolve
);
}
else
{
return
reject
(
"Not a PDF.js document"
);
...
...
@@ -130,9 +160,8 @@
var
_this
=
this
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
_this
.
_pendingScanResolve
=
resolve
;
return
_this
.
_waitForInit
().
then
(
function
()
{
return
PDFView
.
getPage
(
1
).
then
(
function
()
{
console
.
log
(
"Scanning document for text..."
);
return
_this
.
waitForInit
().
then
(
function
()
{
return
_this
.
_app
.
pdfDocument
.
getPage
(
1
).
then
(
function
()
{
_this
.
pageInfo
=
[];
return
_this
.
_extractPageText
(
0
);
});
...
...
@@ -141,19 +170,10 @@
};
PDFTextMapper
.
prototype
.
_extractPageText
=
function
(
pageIndex
)
{
var
page
,
pageSource
,
_ref
,
_this
=
this
;
pageSource
=
(
_ref
=
PDFFindController
.
pdfPageSource
)
!=
null
?
_ref
:
PDFView
.
findController
.
pdfPageSource
;
page
=
pageSource
.
pages
[
pageIndex
];
if
((
page
!=
null
?
page
.
pdfPage
:
void
0
)
==
null
)
{
setTimeout
((
function
()
{
return
_this
.
_extractPageText
(
pageIndex
);
}),
100
);
return
;
}
return
page
.
getTextContent
().
then
(
function
(
data
)
{
var
content
,
rawContent
,
text
,
textData
,
_ref1
,
_ref2
;
textData
=
(
_ref1
=
(
_ref2
=
data
.
bidiTexts
)
!=
null
?
_ref2
:
data
.
items
)
!=
null
?
_ref1
:
data
;
var
_this
=
this
;
return
this
.
_tryExtractPage
(
pageIndex
).
then
(
function
(
data
)
{
var
content
,
rawContent
,
text
,
textData
,
_ref
,
_ref1
;
textData
=
(
_ref
=
(
_ref1
=
data
.
bidiTexts
)
!=
null
?
_ref1
:
data
.
items
)
!=
null
?
_ref
:
data
;
rawContent
=
((
function
()
{
var
_i
,
_len
,
_results
;
_results
=
[];
...
...
@@ -168,7 +188,7 @@
index
:
pageIndex
,
content
:
content
};
if
(
pageIndex
===
PDFView
.
pages
.
length
-
1
)
{
if
(
pageIndex
===
_this
.
getPageCount
()
-
1
)
{
return
_this
.
_finishScan
();
}
else
{
return
_this
.
_extractPageText
(
pageIndex
+
1
);
...
...
@@ -192,9 +212,17 @@
return
this
.
pageInfo
[
index
];
};
PDFTextMapper
.
prototype
.
getDocumentFingerprint
=
function
()
{
return
this
.
_app
.
documentFingerprint
;
};
PDFTextMapper
.
prototype
.
getDocumentInfo
=
function
()
{
return
this
.
app
.
documentInfo
;
};
return
PDFTextMapper
;
})(
window
.
PageTextMapperCore
);
})(
PageTextMapperCore
);
Annotator
.
Plugin
.
PDF
=
(
function
(
_super
)
{
var
$
;
...
...
@@ -222,7 +250,7 @@
};
PDF
.
prototype
.
_isPDF
=
function
()
{
return
window
.
PDFJS
;
return
PDFTextMapper
.
applicable
()
;
};
PDF
.
prototype
.
_getDocumentURI
=
function
()
{
...
...
@@ -239,7 +267,7 @@
PDF
.
prototype
.
_getFingerPrintURI
=
function
()
{
var
fingerprint
;
fingerprint
=
PDFView
.
documentFingerprint
;
fingerprint
=
this
.
annotator
.
domMapper
.
getDocumentFingerprint
()
;
return
"urn:x-pdf:"
+
fingerprint
;
};
...
...
@@ -252,7 +280,7 @@
PDF
.
prototype
.
_getTitle
=
function
()
{
var
title
,
_ref1
;
title
=
(
_ref1
=
PDFView
.
documentInfo
.
Title
)
!=
null
?
_ref1
.
trim
()
:
void
0
;
title
=
(
_ref1
=
this
.
annotator
.
domMapper
.
getDocumentInfo
()
.
Title
)
!=
null
?
_ref1
.
trim
()
:
void
0
;
if
((
title
!=
null
)
&&
title
!==
""
)
{
return
title
;
}
else
{
...
...
@@ -284,10 +312,8 @@
PDF
.
prototype
.
getMetaData
=
function
()
{
var
_this
=
this
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
init
;
init
=
_this
.
annotator
.
domMapper
.
_waitForInit
;
if
(
init
!=
null
)
{
return
init
().
then
(
function
()
{
if
(
_this
.
annotator
.
domMapper
.
waitForInit
!=
null
)
{
return
_this
.
annotator
.
domMapper
.
waitForInit
().
then
(
function
()
{
return
resolve
(
_this
.
_metadata
());
});
}
else
{
...
...
@@ -312,4 +338,3 @@
})(
Annotator
.
Plugin
);
}).
call
(
this
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment