mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
For text widgets, get the text from the AP stream instead of from the format callback (bug 1825002)
When fixing bug 1766987, I thought the field formatted value came from the result of the format callback: I was wrong. The format callback is ran but the value is unused (maybe it's useful to set some global vars... or it's just a bug in Acrobat). Anyway the value to display is the one rendered in the AP stream. The field value setter has been simplified and that fixes issue #16409.
This commit is contained in:
parent
5ae353cf4d
commit
177036e6ae
7 changed files with 93 additions and 35 deletions
|
@ -1049,7 +1049,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||
const storedData = storage.getValue(id, {
|
||||
value: this.data.fieldValue,
|
||||
});
|
||||
let textContent = storedData.formattedValue || storedData.value || "";
|
||||
let textContent = storedData.value || "";
|
||||
const maxLen = storage.getValue(id, {
|
||||
charLimit: this.data.maxLen,
|
||||
}).charLimit;
|
||||
|
@ -1057,23 +1057,29 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||
textContent = textContent.slice(0, maxLen);
|
||||
}
|
||||
|
||||
let fieldFormattedValues =
|
||||
storedData.formattedValue || this.data.textContent?.join("\n") || null;
|
||||
if (fieldFormattedValues && this.data.comb) {
|
||||
fieldFormattedValues = fieldFormattedValues.replaceAll(/\s+/g, "");
|
||||
}
|
||||
|
||||
const elementData = {
|
||||
userValue: textContent,
|
||||
formattedValue: null,
|
||||
formattedValue: fieldFormattedValues,
|
||||
lastCommittedValue: null,
|
||||
commitKey: 1,
|
||||
};
|
||||
|
||||
if (this.data.multiLine) {
|
||||
element = document.createElement("textarea");
|
||||
element.textContent = textContent;
|
||||
element.textContent = fieldFormattedValues ?? textContent;
|
||||
if (this.data.doNotScroll) {
|
||||
element.style.overflowY = "hidden";
|
||||
}
|
||||
} else {
|
||||
element = document.createElement("input");
|
||||
element.type = "text";
|
||||
element.setAttribute("value", textContent);
|
||||
element.setAttribute("value", fieldFormattedValues ?? textContent);
|
||||
if (this.data.doNotScroll) {
|
||||
element.style.overflowX = "hidden";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue