Merge pull request #16555 from calixteman/empty_freetext

[Editor] Don't add an editor for empty FreeText annotations
This commit is contained in:
calixteman 2023-06-15 19:44:13 +02:00 committed by GitHub
commit 64520a0c63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -539,6 +539,10 @@ class FreeTextEditor extends AnnotationEditor {
textContent,
page: { pageNumber },
} = data;
if (!textContent || textContent.length === 0) {
// Empty annotation.
return null;
}
initialData = data = {
annotationType: AnnotationEditorType.FREETEXT,
color: Array.from(fontColor),

View File

@ -993,6 +993,29 @@ describe("FreeText Editor", () => {
});
});
describe("FreeText (update existing but not empty ones)", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("issue14438.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
await closePages(pages);
});
it("must update an existing annotation but not an empty one", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.click("#editorFreeText");
const editorIds = await getEditors(page, "freeText");
expect(editorIds.length).withContext(`In ${browserName}`).toEqual(1);
})
);
});
});
describe("FreeText (delete existing)", () => {
let pages;