Commit bc535a76 authored by csillag's avatar csillag

Update Annotator to 0d3b9203 (typed-packaging branch)

 - PDF: Support latest PDF.js (v1.0.277)
 - TextRange: Handle an error condition
parent dfd9e2dd
// Generated by CoffeeScript 1.6.3
/*
** Annotator 1.2.6-dev-84bccda
** Annotator 1.2.6-dev-0d3b920
** 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-07-22 20:43:16Z
** Built at: 2014-08-19 23:59:29Z
*/
......@@ -105,24 +105,36 @@
return text.replace(this._extractionPattern, " ");
};
PDFTextMapper.prototype._waitForInit = function() {
var tryIt;
tryIt = function(resolve) {
var _this = this;
if (PDFView.documentFingerprint) {
return resolve();
} else {
return setTimeout((function() {
console.log("OK, let's try again");
return tryIt(resolve);
}), 100);
}
};
return new Promise(function(resolve, reject) {
return tryIt(resolve);
});
};
PDFTextMapper.prototype.scan = function() {
var _ref,
_this = this;
if (this.pendingScan == null) {
this.pendingScan = (_ref = typeof PDFJS.Promise === "function" ? new PDFJS.Promise() : void 0) != null ? _ref : typeof PDFJS.LegacyPromise === "function" ? new PDFJS.LegacyPromise() : void 0;
}
if (PDFView.pdfDocument == null) {
setTimeout((function() {
return _this.scan();
}), 500);
return this.pendingScan;
}
PDFView.getPage(1).then(function() {
console.log("Scanning document for text...");
_this.pageInfo = [];
return _this._extractPageText(0);
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...");
_this.pageInfo = [];
return _this._extractPageText(0);
});
});
});
return this.pendingScan;
};
PDFTextMapper.prototype._extractPageText = function(pageIndex) {
......@@ -136,13 +148,13 @@
return;
}
return page.getTextContent().then(function(data) {
var content, rawContent, text;
var content, rawContent, text, textData, _ref, _ref1;
textData = (_ref = (_ref1 = data.bidiTexts) != null ? _ref1 : data.items) != null ? _ref : data;
rawContent = ((function() {
var _i, _len, _ref, _ref1, _results;
_ref1 = (_ref = data.bidiTexts) != null ? _ref : data;
var _i, _len, _results;
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
text = _ref1[_i];
for (_i = 0, _len = textData.length; _i < _len; _i++) {
text = textData[_i];
_results.push(text.str);
}
return _results;
......@@ -162,7 +174,7 @@
PDFTextMapper.prototype._finishScan = function() {
this._onHavePageContents();
this.pendingScan.resolve();
this._pendingScanResolve();
return this._onAfterScan();
};
......
// Generated by CoffeeScript 1.6.3
/*
** Annotator 1.2.6-dev-5c36e53
** Annotator 1.2.6-dev-0d3b920
** 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-06-17 21:13:15Z
** Built at: 2014-08-19 23:59:28Z
*/
......@@ -86,7 +86,7 @@
};
TextRange.prototype.createFromRangeSelector = function(annotation, target) {
var currentQuote, endInfo, endOffset, error, normedRange, range, savedQuote, selector, startInfo, startOffset, _base, _ref1, _ref2;
var currentQuote, endInfo, endOffset, error, normedRange, range, rawQuote, savedQuote, selector, startInfo, startOffset, _base, _ref1, _ref2;
selector = this.annotator.findSelector(target.selector, "RangeSelector");
if (selector == null) {
return null;
......@@ -98,7 +98,22 @@
error = _error;
return null;
}
currentQuote = this.annotator.normalizeString(this.annotator.domMapper.getInfoForNode != null ? (startInfo = this.annotator.domMapper.getInfoForNode(normedRange.start), startOffset = startInfo.start, endInfo = this.annotator.domMapper.getInfoForNode(normedRange.end), endOffset = endInfo.end, this.annotator.domMapper.getCorpus().slice(startOffset, +(endOffset - 1) + 1 || 9e9).trim()) : normedRange.text().trim());
if (this.annotator.domMapper.getInfoForNode != null) {
startInfo = this.annotator.domMapper.getInfoForNode(normedRange.start);
if (!startInfo) {
return null;
}
startOffset = startInfo.start;
endInfo = this.annotator.domMapper.getInfoForNode(normedRange.end);
if (!endInfo) {
return null;
}
endOffset = endInfo.end;
rawQuote = this.annotator.domMapper.getCorpus().slice(startOffset, +(endOffset - 1) + 1 || 9e9).trim();
} else {
rawQuote = normedRange.text().trim();
}
currentQuote = this.annotator.normalizeString(rawQuote);
savedQuote = typeof (_base = this.annotator).getQuoteForTarget === "function" ? _base.getQuoteForTarget(target) : void 0;
if ((savedQuote != null) && currentQuote !== savedQuote) {
return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment