Implement caret annotations

The file `test/pdfs/annotation-caret-ink.pdf` is already available in
the repository as a reference test for this since I supplied it for
another patch that implemented ink annotations.
This commit is contained in:
Tim van der Meij 2019-04-09 23:35:32 +02:00
parent ce62373db3
commit 4055d0a302
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
3 changed files with 40 additions and 0 deletions

View file

@ -83,6 +83,9 @@ class AnnotationElementFactory {
case AnnotationType.POLYLINE:
return new PolylineAnnotationElement(parameters);
case AnnotationType.CARET:
return new CaretAnnotationElement(parameters);
case AnnotationType.INK:
return new InkAnnotationElement(parameters);
@ -1017,6 +1020,30 @@ class PolygonAnnotationElement extends PolylineAnnotationElement {
}
}
class CaretAnnotationElement extends AnnotationElement {
constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup ||
parameters.data.title || parameters.data.contents);
super(parameters, isRenderable, /* ignoreBorder = */ true);
}
/**
* Render the caret annotation's HTML element in the empty container.
*
* @public
* @memberof CaretAnnotationElement
* @returns {HTMLSectionElement}
*/
render() {
this.container.className = 'caretAnnotation';
if (!this.data.hasPopup) {
this._createPopup(this.container, null, this.data);
}
return this.container;
}
}
class InkAnnotationElement extends AnnotationElement {
constructor(parameters) {
let isRenderable = !!(parameters.data.hasPopup ||