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

Merge pull request #13272 from calixteman/issue13271

Update all the text widgets having the same name with the same value
This commit is contained in:
Tim van der Meij 2021-04-23 21:08:54 +02:00 committed by GitHub
commit da0e7ea969
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 1 deletions

View file

@ -625,6 +625,18 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
super(parameters, { isRenderable });
}
setPropertyOnSiblings(base, key, value, keyInStorage) {
const storage = this.annotationStorage;
for (const element of document.getElementsByName(base.name)) {
if (element !== base) {
element[key] = value;
const data = Object.create(null);
data[keyInStorage] = value;
storage.setValue(element.getAttribute("id"), data);
}
}
}
render() {
const storage = this.annotationStorage;
const id = this.data.id;
@ -660,8 +672,14 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
elementData.userValue = textContent;
element.setAttribute("id", id);
element.addEventListener("input", function (event) {
element.addEventListener("input", event => {
storage.setValue(id, { value: event.target.value });
this.setPropertyOnSiblings(
element,
"value",
event.target.value,
"value"
);
});
let blurListener = event => {