mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Implement free text annotations
This commit is contained in:
parent
62dc431af6
commit
ae2a4dc3dd
6 changed files with 47 additions and 0 deletions
|
@ -92,6 +92,9 @@ class AnnotationFactory {
|
|||
case 'Popup':
|
||||
return new PopupAnnotation(parameters);
|
||||
|
||||
case 'FreeText':
|
||||
return new FreeTextAnnotation(parameters);
|
||||
|
||||
case 'Line':
|
||||
return new LineAnnotation(parameters);
|
||||
|
||||
|
@ -964,6 +967,14 @@ class PopupAnnotation extends Annotation {
|
|||
}
|
||||
}
|
||||
|
||||
class FreeTextAnnotation extends MarkupAnnotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
||||
this.data.annotationType = AnnotationType.FREETEXT;
|
||||
}
|
||||
}
|
||||
|
||||
class LineAnnotation extends MarkupAnnotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
|
|
@ -71,6 +71,9 @@ class AnnotationElementFactory {
|
|||
case AnnotationType.POPUP:
|
||||
return new PopupAnnotationElement(parameters);
|
||||
|
||||
case AnnotationType.FREETEXT:
|
||||
return new FreeTextAnnotationElement(parameters);
|
||||
|
||||
case AnnotationType.LINE:
|
||||
return new LineAnnotationElement(parameters);
|
||||
|
||||
|
@ -807,6 +810,30 @@ class PopupElement {
|
|||
}
|
||||
}
|
||||
|
||||
class FreeTextAnnotationElement extends AnnotationElement {
|
||||
constructor(parameters) {
|
||||
const isRenderable = !!(parameters.data.hasPopup ||
|
||||
parameters.data.title || parameters.data.contents);
|
||||
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the free text annotation's HTML element in the empty container.
|
||||
*
|
||||
* @public
|
||||
* @memberof FreeTextAnnotationElement
|
||||
* @returns {HTMLSectionElement}
|
||||
*/
|
||||
render() {
|
||||
this.container.className = 'freeTextAnnotation';
|
||||
|
||||
if (!this.data.hasPopup) {
|
||||
this._createPopup(this.container, null, this.data);
|
||||
}
|
||||
return this.container;
|
||||
}
|
||||
}
|
||||
|
||||
class LineAnnotationElement extends AnnotationElement {
|
||||
constructor(parameters) {
|
||||
let isRenderable = !!(parameters.data.hasPopup ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue