1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 00:28:06 +02:00

Update all the text widgets having the same name with the same value

This commit is contained in:
Calixte Denizet 2021-04-20 18:32:23 +02:00
parent fd82adccfa
commit e868ab0051
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 => {