mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-09 23:04:02 +02:00
Merge pull request #21034 from Snuffleupagus/collectAnnotationsByType-fixes
A couple of small `collectAnnotationsByType` improvements
This commit is contained in:
commit
38981ce638
@ -83,8 +83,6 @@ import { XRef } from "./xref.js";
|
||||
const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
|
||||
|
||||
class Page {
|
||||
#areAnnotationsCached = false;
|
||||
|
||||
#resourcesPromise = null;
|
||||
|
||||
constructor({
|
||||
@ -874,8 +872,6 @@ class Page {
|
||||
return sortedAnnotations;
|
||||
});
|
||||
|
||||
this.#areAnnotationsCached = true;
|
||||
|
||||
return shadow(this, "_parsedAnnotations", promise);
|
||||
}
|
||||
|
||||
@ -897,7 +893,7 @@ class Page {
|
||||
) {
|
||||
const { pageIndex } = this;
|
||||
|
||||
if (this.#areAnnotationsCached) {
|
||||
if (Object.hasOwn(this, "_parsedAnnotations")) {
|
||||
const cachedAnnotations = await this._parsedAnnotations;
|
||||
for (const { data } of cachedAnnotations) {
|
||||
if (!types || types.has(data.annotationType)) {
|
||||
@ -909,6 +905,8 @@ class Page {
|
||||
}
|
||||
|
||||
const annots = await this.pdfManager.ensure(this, "annotations");
|
||||
let partialEvaluator;
|
||||
|
||||
for (const annotationRef of annots) {
|
||||
promises.push(
|
||||
AnnotationFactory.create(
|
||||
@ -927,7 +925,8 @@ class Page {
|
||||
}
|
||||
annotation.data.pageIndex = pageIndex;
|
||||
if (annotation.hasTextContent && annotation.viewable) {
|
||||
const partialEvaluator = this.#createPartialEvaluator(handler);
|
||||
partialEvaluator ??= this.#createPartialEvaluator(handler);
|
||||
|
||||
await annotation.extractTextContent(partialEvaluator, task, [
|
||||
-Infinity,
|
||||
-Infinity,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user