diff --git a/src/core/annotation.js b/src/core/annotation.js index 229f15707..6661b43cb 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -107,6 +107,9 @@ class AnnotationFactory { case 'Polygon': return new PolygonAnnotation(parameters); + case 'Caret': + return new CaretAnnotation(parameters); + case 'Ink': return new InkAnnotation(parameters); @@ -1026,6 +1029,15 @@ class PolygonAnnotation extends PolylineAnnotation { } } +class CaretAnnotation extends Annotation { + constructor(parameters) { + super(parameters); + + this.data.annotationType = AnnotationType.CARET; + this._preparePopup(parameters.dict); + } +} + class InkAnnotation extends Annotation { constructor(parameters) { super(parameters); diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index b568731d7..4f7c9c77d 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -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 || diff --git a/web/annotation_layer_builder.css b/web/annotation_layer_builder.css index 8e9fd486e..acb6d8d3d 100644 --- a/web/annotation_layer_builder.css +++ b/web/annotation_layer_builder.css @@ -188,6 +188,7 @@ .annotationLayer .circleAnnotation svg ellipse, .annotationLayer .polylineAnnotation svg polyline, .annotationLayer .polygonAnnotation svg polygon, +.annotationLayer .caretAnnotation, .annotationLayer .inkAnnotation svg polyline, .annotationLayer .stampAnnotation, .annotationLayer .fileAttachmentAnnotation {