Merge pull request #10723 from timvandermeij/caret-annotation

Implement caret annotations
This commit is contained in:
Tim van der Meij 2019-04-11 00:03:21 +02:00 committed by GitHub
commit 74561f58b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 0 deletions

View File

@ -107,6 +107,9 @@ class AnnotationFactory {
case 'Polygon': case 'Polygon':
return new PolygonAnnotation(parameters); return new PolygonAnnotation(parameters);
case 'Caret':
return new CaretAnnotation(parameters);
case 'Ink': case 'Ink':
return new InkAnnotation(parameters); 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 { class InkAnnotation extends Annotation {
constructor(parameters) { constructor(parameters) {
super(parameters); super(parameters);

View File

@ -83,6 +83,9 @@ class AnnotationElementFactory {
case AnnotationType.POLYLINE: case AnnotationType.POLYLINE:
return new PolylineAnnotationElement(parameters); return new PolylineAnnotationElement(parameters);
case AnnotationType.CARET:
return new CaretAnnotationElement(parameters);
case AnnotationType.INK: case AnnotationType.INK:
return new InkAnnotationElement(parameters); 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 { class InkAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
let isRenderable = !!(parameters.data.hasPopup || let isRenderable = !!(parameters.data.hasPopup ||

View File

@ -188,6 +188,7 @@
.annotationLayer .circleAnnotation svg ellipse, .annotationLayer .circleAnnotation svg ellipse,
.annotationLayer .polylineAnnotation svg polyline, .annotationLayer .polylineAnnotation svg polyline,
.annotationLayer .polygonAnnotation svg polygon, .annotationLayer .polygonAnnotation svg polygon,
.annotationLayer .caretAnnotation,
.annotationLayer .inkAnnotation svg polyline, .annotationLayer .inkAnnotation svg polyline,
.annotationLayer .stampAnnotation, .annotationLayer .stampAnnotation,
.annotationLayer .fileAttachmentAnnotation { .annotationLayer .fileAttachmentAnnotation {