1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

[JS] Format all the fields if any when the document is open (bug 1766987)

- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1766987.
This commit is contained in:
Calixte Denizet 2022-05-22 14:37:17 +02:00
parent 42a6217427
commit 9407adc416
4 changed files with 62 additions and 0 deletions

View file

@ -76,6 +76,11 @@ class EventDispatcher {
event.name = baseEvent.name;
}
if (id === "doc") {
if (event.name === "Open") {
// Before running the Open event, we format all the fields
// (see bug 1766987).
this.formatAll();
}
this._document.obj._dispatchDocEvent(event.name);
} else if (id === "page") {
this._document.obj._dispatchPageEvent(
@ -180,6 +185,20 @@ class EventDispatcher {
}
}
formatAll() {
// Run format actions if any for all the fields.
const event = (globalThis.event = new Event({}));
for (const source of Object.values(this._objects)) {
event.value = source.obj.value;
if (this.runActions(source, source, event, "Format")) {
source.obj._send({
id: source.obj._id,
formattedValue: event.value?.toString?.(),
});
}
}
}
runValidation(source, event) {
const didValidateRun = this.runActions(source, source, event, "Validate");
if (event.rc) {