mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Implement creation date only for markup annotations
The specification states that `CreationDate` is only available for markup annotations instead of for all annotation types. Moreover, popup annotations are not markup annotations according to the specification, so the creation date inheritance from the parent annotation is also removed there (note that only the modification date is used in e.g., the viewer).
This commit is contained in:
parent
cf07918ccb
commit
bc1eb49a77
2 changed files with 47 additions and 41 deletions
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
Annotation, AnnotationBorderStyle, AnnotationFactory
|
||||
Annotation, AnnotationBorderStyle, AnnotationFactory, MarkupAnnotation
|
||||
} from '../../src/core/annotation';
|
||||
import {
|
||||
AnnotationBorderStyleType, AnnotationFieldFlag, AnnotationFlag,
|
||||
|
@ -145,20 +145,6 @@ describe('annotation', function() {
|
|||
expect(annotation.contents).toEqual('');
|
||||
});
|
||||
|
||||
it('should set and get a valid creation date', function() {
|
||||
const annotation = new Annotation({ dict, ref, });
|
||||
annotation.setCreationDate('D:20190422');
|
||||
|
||||
expect(annotation.creationDate).toEqual('D:20190422');
|
||||
});
|
||||
|
||||
it('should set and get an invalid creation date', function() {
|
||||
const annotation = new Annotation({ dict, ref, });
|
||||
annotation.setCreationDate(undefined);
|
||||
|
||||
expect(annotation.creationDate).toEqual(null);
|
||||
});
|
||||
|
||||
it('should set and get a valid modification date', function() {
|
||||
const annotation = new Annotation({ dict, ref, });
|
||||
annotation.setModificationDate('D:20190422');
|
||||
|
@ -166,7 +152,7 @@ describe('annotation', function() {
|
|||
expect(annotation.modificationDate).toEqual('D:20190422');
|
||||
});
|
||||
|
||||
it('should set and get an invalid modification date', function() {
|
||||
it('should not set and get an invalid modification date', function() {
|
||||
const annotation = new Annotation({ dict, ref, });
|
||||
annotation.setModificationDate(undefined);
|
||||
|
||||
|
@ -331,6 +317,34 @@ describe('annotation', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('MarkupAnnotation', function() {
|
||||
let dict, ref;
|
||||
|
||||
beforeAll(function(done) {
|
||||
dict = new Dict();
|
||||
ref = new Ref(1, 0);
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
dict = ref = null;
|
||||
});
|
||||
|
||||
it('should set and get a valid creation date', function() {
|
||||
const markupAnnotation = new MarkupAnnotation({ dict, ref, });
|
||||
markupAnnotation.setCreationDate('D:20190422');
|
||||
|
||||
expect(markupAnnotation.creationDate).toEqual('D:20190422');
|
||||
});
|
||||
|
||||
it('should not set and get an invalid creation date', function() {
|
||||
const markupAnnotation = new MarkupAnnotation({ dict, ref, });
|
||||
markupAnnotation.setCreationDate(undefined);
|
||||
|
||||
expect(markupAnnotation.creationDate).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('LinkAnnotation', function() {
|
||||
it('should correctly parse a URI action', function(done) {
|
||||
const actionDict = new Dict();
|
||||
|
@ -1446,7 +1460,6 @@ describe('annotation', function() {
|
|||
const parentDict = new Dict();
|
||||
parentDict.set('Type', Name.get('Annot'));
|
||||
parentDict.set('Subtype', Name.get('Text'));
|
||||
parentDict.set('CreationDate', 'D:20190422');
|
||||
parentDict.set('M', 'D:20190423');
|
||||
parentDict.set('C', [0, 0, 1]);
|
||||
|
||||
|
@ -1463,7 +1476,6 @@ describe('annotation', function() {
|
|||
AnnotationFactory.create(xref, popupRef, pdfManagerMock,
|
||||
idFactoryMock).then(({ data, viewable, }) => {
|
||||
expect(data.annotationType).toEqual(AnnotationType.POPUP);
|
||||
expect(data.creationDate).toEqual('D:20190422');
|
||||
expect(data.modificationDate).toEqual('D:20190423');
|
||||
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
||||
done();
|
||||
|
@ -1488,7 +1500,6 @@ describe('annotation', function() {
|
|||
AnnotationFactory.create(xref, popupRef, pdfManagerMock,
|
||||
idFactoryMock).then(({ data, viewable, }) => {
|
||||
expect(data.annotationType).toEqual(AnnotationType.POPUP);
|
||||
expect(data.creationDate).toEqual(null);
|
||||
expect(data.modificationDate).toEqual(null);
|
||||
expect(data.color).toEqual(null);
|
||||
done();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue