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

[Editor] Don't make editable an empty freetext annotation

This commit is contained in:
Calixte Denizet 2023-06-21 11:07:14 +02:00
parent 7588418b09
commit 19f7a8b899
3 changed files with 44 additions and 1 deletions

View file

@ -999,6 +999,9 @@ class Annotation {
enqueue(chunk, size) {
for (const item of chunk.items) {
if (item.str === undefined) {
continue;
}
buffer.push(item.str);
if (item.hasEOL) {
text.push(buffer.join(""));
@ -1022,7 +1025,7 @@ class Annotation {
text.push(buffer.join(""));
}
if (text.length > 0) {
if (text.length > 1 || text[0]) {
this.data.textContent = text;
}
}

View file

@ -541,6 +541,8 @@ class FreeTextEditor extends AnnotationEditor {
page: { pageNumber },
},
} = data;
// textContent is supposed to be an array of strings containing each line
// of text. However, it can be null or empty.
if (!textContent || textContent.length === 0) {
// Empty annotation.
return null;