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:
parent
7588418b09
commit
19f7a8b899
3 changed files with 44 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue