mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 23:58:07 +02:00
Merge pull request #12567 from calixteman/hidden
[api-minor] JS -- hidden annotations must be built in case a script show them
This commit is contained in:
commit
4ba28de260
9 changed files with 210 additions and 100 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -179,6 +179,7 @@
|
|||
!devicen.pdf
|
||||
!cmykjpeg.pdf
|
||||
!issue840.pdf
|
||||
!160F-2019.pdf
|
||||
!issue4402_reduced.pdf
|
||||
!issue845r.pdf
|
||||
!issue3405r.pdf
|
||||
|
|
BIN
test/pdfs/160F-2019.pdf
Normal file
BIN
test/pdfs/160F-2019.pdf
Normal file
Binary file not shown.
|
@ -2214,6 +2214,19 @@
|
|||
"lastPage": 1,
|
||||
"type": "load"
|
||||
},
|
||||
{ "id": "160F-2019",
|
||||
"file": "pdfs/160F-2019.pdf",
|
||||
"md5": "71591f11ee717e12887f529c84d5ae89",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"427R": {
|
||||
"hidden": false,
|
||||
"value": "hello world"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "issue6342-eq",
|
||||
"file": "pdfs/issue6342.pdf",
|
||||
"md5": "2ea85ca8d17117798f105be88bdb2bfd",
|
||||
|
@ -2818,7 +2831,9 @@
|
|||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"2795R": "氏 名 又 は 名 称 Full name"
|
||||
"2795R": {
|
||||
"value": "氏 名 又 は 名 称 Full name"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "issue7598",
|
||||
|
@ -3682,7 +3697,9 @@
|
|||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"1605R": true
|
||||
"1605R": {
|
||||
"value": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "clippath",
|
||||
|
@ -4186,11 +4203,21 @@
|
|||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"29R": true,
|
||||
"33R": true,
|
||||
"37R": true,
|
||||
"65R": true,
|
||||
"69R": true
|
||||
"29R": {
|
||||
"value": true
|
||||
},
|
||||
"33R": {
|
||||
"value": true
|
||||
},
|
||||
"37R": {
|
||||
"value": true
|
||||
},
|
||||
"65R": {
|
||||
"value": true
|
||||
},
|
||||
"69R": {
|
||||
"value": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "issue1171.pdf",
|
||||
|
@ -4584,13 +4611,27 @@
|
|||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"61R": "Single line, unlimited length",
|
||||
"62R": "Single lin",
|
||||
"63R": "Single line, center aligned",
|
||||
"64R": "Single line, right aligned",
|
||||
"65R": "",
|
||||
"66R": "zyxwvutsrqponmlkjihgfedcba",
|
||||
"67R": "Multiline\nstring"
|
||||
"61R": {
|
||||
"value": "Single line, unlimited length"
|
||||
},
|
||||
"62R": {
|
||||
"value": "Single lin"
|
||||
},
|
||||
"63R": {
|
||||
"value": "Single line, center aligned"
|
||||
},
|
||||
"64R": {
|
||||
"value": "Single line, right aligned"
|
||||
},
|
||||
"65R": {
|
||||
"value": ""
|
||||
},
|
||||
"66R": {
|
||||
"value": "zyxwvutsrqponmlkjihgfedcba"
|
||||
},
|
||||
"67R": {
|
||||
"value": "Multiline\nstring"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "annotation-choice-widget-annotations",
|
||||
|
@ -4614,11 +4655,21 @@
|
|||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"57R": "Ipsum",
|
||||
"58R": "Lorem",
|
||||
"59R": "Dolor",
|
||||
"62R": "Sit",
|
||||
"63R": ""
|
||||
"57R": {
|
||||
"value": "Ipsum"
|
||||
},
|
||||
"58R": {
|
||||
"value": "Lorem"
|
||||
},
|
||||
"59R": {
|
||||
"value": "Dolor"
|
||||
},
|
||||
"62R": {
|
||||
"value": "Sit"
|
||||
},
|
||||
"63R": {
|
||||
"value": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "issue12233-forms",
|
||||
|
@ -4637,7 +4688,9 @@
|
|||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"20R": true
|
||||
"20R": {
|
||||
"value": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "issue11931",
|
||||
|
@ -4673,15 +4726,33 @@
|
|||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"105R": true,
|
||||
"106R": false,
|
||||
"107R": false,
|
||||
"108R": true,
|
||||
"109R": false,
|
||||
"110R": false,
|
||||
"111R": true,
|
||||
"112R": false,
|
||||
"113R": false
|
||||
"105R": {
|
||||
"value": true
|
||||
},
|
||||
"106R": {
|
||||
"value": false
|
||||
},
|
||||
"107R": {
|
||||
"value": false
|
||||
},
|
||||
"108R": {
|
||||
"value": true
|
||||
},
|
||||
"109R": {
|
||||
"value": false
|
||||
},
|
||||
"110R": {
|
||||
"value": false
|
||||
},
|
||||
"111R": {
|
||||
"value": true
|
||||
},
|
||||
"112R": {
|
||||
"value": false
|
||||
},
|
||||
"113R": {
|
||||
"value": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "annotation-polyline-polygon",
|
||||
|
|
|
@ -1602,7 +1602,7 @@ describe("annotation", function () {
|
|||
.then(annotation => {
|
||||
const id = annotation.data.id;
|
||||
const annotationStorage = {};
|
||||
annotationStorage[id] = "test\\print";
|
||||
annotationStorage[id] = { value: "test\\print" };
|
||||
return annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -1687,7 +1687,7 @@ describe("annotation", function () {
|
|||
.then(annotation => {
|
||||
const id = annotation.data.id;
|
||||
const annotationStorage = {};
|
||||
annotationStorage[id] = "test (print)";
|
||||
annotationStorage[id] = { value: "test (print)" };
|
||||
return annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -1723,7 +1723,7 @@ describe("annotation", function () {
|
|||
.then(annotation => {
|
||||
const id = annotation.data.id;
|
||||
const annotationStorage = {};
|
||||
annotationStorage[id] = "mypassword";
|
||||
annotationStorage[id] = { value: "mypassword" };
|
||||
return annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -1756,9 +1756,11 @@ describe("annotation", function () {
|
|||
.then(annotation => {
|
||||
const id = annotation.data.id;
|
||||
const annotationStorage = {};
|
||||
annotationStorage[id] =
|
||||
"a aa aaa aaaa aaaaa aaaaaa " +
|
||||
"pneumonoultramicroscopicsilicovolcanoconiosis";
|
||||
annotationStorage[id] = {
|
||||
value:
|
||||
"a aa aaa aaaa aaaaa aaaaaa " +
|
||||
"pneumonoultramicroscopicsilicovolcanoconiosis",
|
||||
};
|
||||
return annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -1823,15 +1825,17 @@ describe("annotation", function () {
|
|||
.then(annotation => {
|
||||
const id = annotation.data.id;
|
||||
const annotationStorage = {};
|
||||
annotationStorage[id] =
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r" +
|
||||
"Aliquam vitae felis ac lectus bibendum ultricies quis non diam.\n" +
|
||||
"Morbi id porttitor quam, a iaculis dui.\r\n" +
|
||||
"Pellentesque habitant morbi tristique senectus et " +
|
||||
"netus et malesuada fames ac turpis egestas.\n\r\n\r" +
|
||||
"Nulla consectetur, ligula in tincidunt placerat, " +
|
||||
"velit augue consectetur orci, sed mattis libero nunc ut massa.\r" +
|
||||
"Etiam facilisis tempus interdum.";
|
||||
annotationStorage[id] = {
|
||||
value:
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r" +
|
||||
"Aliquam vitae felis ac lectus bibendum ultricies quis non diam.\n" +
|
||||
"Morbi id porttitor quam, a iaculis dui.\r\n" +
|
||||
"Pellentesque habitant morbi tristique senectus et " +
|
||||
"netus et malesuada fames ac turpis egestas.\n\r\n\r" +
|
||||
"Nulla consectetur, ligula in tincidunt placerat, " +
|
||||
"velit augue consectetur orci, sed mattis libero nunc ut massa.\r" +
|
||||
"Etiam facilisis tempus interdum.",
|
||||
};
|
||||
return annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -1865,7 +1869,7 @@ describe("annotation", function () {
|
|||
.then(annotation => {
|
||||
const id = annotation.data.id;
|
||||
const annotationStorage = {};
|
||||
annotationStorage[id] = "aa(aa)a\\";
|
||||
annotationStorage[id] = { value: "aa(aa)a\\" };
|
||||
return annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -1898,7 +1902,7 @@ describe("annotation", function () {
|
|||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = "hello world";
|
||||
annotationStorage[annotation.data.id] = { value: "hello world" };
|
||||
return annotation.save(partialEvaluator, task, annotationStorage);
|
||||
}, done.fail)
|
||||
.then(data => {
|
||||
|
@ -2151,7 +2155,7 @@ describe("annotation", function () {
|
|||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = true;
|
||||
annotationStorage[annotation.data.id] = { value: true };
|
||||
return annotation.getOperatorList(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -2209,7 +2213,7 @@ describe("annotation", function () {
|
|||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = true;
|
||||
annotationStorage[annotation.data.id] = { value: true };
|
||||
return Promise.all([
|
||||
annotation,
|
||||
annotation.getOperatorList(
|
||||
|
@ -2234,7 +2238,7 @@ describe("annotation", function () {
|
|||
}, done.fail)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = false;
|
||||
annotationStorage[annotation.data.id] = { value: false };
|
||||
return annotation.getOperatorList(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -2292,7 +2296,7 @@ describe("annotation", function () {
|
|||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = true;
|
||||
annotationStorage[annotation.data.id] = { value: true };
|
||||
return Promise.all([
|
||||
annotation,
|
||||
annotation.getOperatorList(
|
||||
|
@ -2317,7 +2321,7 @@ describe("annotation", function () {
|
|||
})
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = true;
|
||||
annotationStorage[annotation.data.id] = { value: true };
|
||||
return annotation.getOperatorList(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -2424,7 +2428,7 @@ describe("annotation", function () {
|
|||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = true;
|
||||
annotationStorage[annotation.data.id] = { value: true };
|
||||
return Promise.all([
|
||||
annotation,
|
||||
annotation.save(partialEvaluator, task, annotationStorage),
|
||||
|
@ -2443,7 +2447,7 @@ describe("annotation", function () {
|
|||
}, done.fail)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = false;
|
||||
annotationStorage[annotation.data.id] = { value: false };
|
||||
return annotation.save(partialEvaluator, task, annotationStorage);
|
||||
}, done.fail)
|
||||
.then(data => {
|
||||
|
@ -2586,7 +2590,7 @@ describe("annotation", function () {
|
|||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = true;
|
||||
annotationStorage[annotation.data.id] = { value: true };
|
||||
return Promise.all([
|
||||
annotation,
|
||||
annotation.getOperatorList(
|
||||
|
@ -2611,7 +2615,7 @@ describe("annotation", function () {
|
|||
}, done.fail)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = false;
|
||||
annotationStorage[annotation.data.id] = { value: false };
|
||||
return annotation.getOperatorList(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -2729,7 +2733,7 @@ describe("annotation", function () {
|
|||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = true;
|
||||
annotationStorage[annotation.data.id] = { value: true };
|
||||
return Promise.all([
|
||||
annotation,
|
||||
annotation.save(partialEvaluator, task, annotationStorage),
|
||||
|
@ -2755,7 +2759,7 @@ describe("annotation", function () {
|
|||
}, done.fail)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = false;
|
||||
annotationStorage[annotation.data.id] = { value: false };
|
||||
return annotation.save(partialEvaluator, task, annotationStorage);
|
||||
}, done.fail)
|
||||
.then(data => {
|
||||
|
@ -2800,7 +2804,7 @@ describe("annotation", function () {
|
|||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = true;
|
||||
annotationStorage[annotation.data.id] = { value: true };
|
||||
return Promise.all([
|
||||
annotation,
|
||||
annotation.save(partialEvaluator, task, annotationStorage),
|
||||
|
@ -3247,7 +3251,7 @@ describe("annotation", function () {
|
|||
.then(annotation => {
|
||||
const id = annotation.data.id;
|
||||
const annotationStorage = {};
|
||||
annotationStorage[id] = "a value";
|
||||
annotationStorage[id] = { value: "a value" };
|
||||
return annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
|
@ -3282,7 +3286,7 @@ describe("annotation", function () {
|
|||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
annotationStorage[annotation.data.id] = "C";
|
||||
annotationStorage[annotation.data.id] = { value: "C" };
|
||||
return annotation.save(partialEvaluator, task, annotationStorage);
|
||||
}, done.fail)
|
||||
.then(data => {
|
||||
|
|
|
@ -19,12 +19,16 @@ describe("AnnotationStorage", function () {
|
|||
describe("GetOrCreateValue", function () {
|
||||
it("should get and set a new value in the annotation storage", function (done) {
|
||||
const annotationStorage = new AnnotationStorage();
|
||||
let value = annotationStorage.getOrCreateValue("123A", "hello world");
|
||||
let value = annotationStorage.getOrCreateValue("123A", {
|
||||
value: "hello world",
|
||||
}).value;
|
||||
expect(value).toEqual("hello world");
|
||||
|
||||
// the second argument is the default value to use
|
||||
// if the key isn't in the storage
|
||||
value = annotationStorage.getOrCreateValue("123A", "an other string");
|
||||
value = annotationStorage.getOrCreateValue("123A", {
|
||||
value: "an other string",
|
||||
}).value;
|
||||
expect(value).toEqual("hello world");
|
||||
done();
|
||||
});
|
||||
|
@ -33,8 +37,8 @@ describe("AnnotationStorage", function () {
|
|||
describe("SetValue", function () {
|
||||
it("should set a new value in the annotation storage", function (done) {
|
||||
const annotationStorage = new AnnotationStorage();
|
||||
annotationStorage.setValue("123A", "an other string");
|
||||
const value = annotationStorage.getAll()["123A"];
|
||||
annotationStorage.setValue("123A", { value: "an other string" });
|
||||
const value = annotationStorage.getAll()["123A"].value;
|
||||
expect(value).toEqual("an other string");
|
||||
done();
|
||||
});
|
||||
|
@ -46,15 +50,15 @@ describe("AnnotationStorage", function () {
|
|||
called = true;
|
||||
};
|
||||
annotationStorage.onSetModified = callback;
|
||||
annotationStorage.getOrCreateValue("asdf", "original");
|
||||
annotationStorage.getOrCreateValue("asdf", { value: "original" });
|
||||
expect(called).toBe(false);
|
||||
|
||||
// not changing value
|
||||
annotationStorage.setValue("asdf", "original");
|
||||
annotationStorage.setValue("asdf", { value: "original" });
|
||||
expect(called).toBe(false);
|
||||
|
||||
// changing value
|
||||
annotationStorage.setValue("asdf", "modified");
|
||||
annotationStorage.setValue("asdf", { value: "modified" });
|
||||
expect(called).toBe(true);
|
||||
done();
|
||||
});
|
||||
|
@ -68,15 +72,15 @@ describe("AnnotationStorage", function () {
|
|||
called = true;
|
||||
};
|
||||
annotationStorage.onResetModified = callback;
|
||||
annotationStorage.getOrCreateValue("asdf", "original");
|
||||
annotationStorage.getOrCreateValue("asdf", { value: "original" });
|
||||
|
||||
// not changing value
|
||||
annotationStorage.setValue("asdf", "original");
|
||||
annotationStorage.setValue("asdf", { value: "original" });
|
||||
annotationStorage.resetModified();
|
||||
expect(called).toBe(false);
|
||||
|
||||
// changing value
|
||||
annotationStorage.setValue("asdf", "modified");
|
||||
annotationStorage.setValue("asdf", { value: "modified" });
|
||||
annotationStorage.resetModified();
|
||||
expect(called).toBe(true);
|
||||
done();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue