Merge pull request #16555 from calixteman/empty_freetext
[Editor] Don't add an editor for empty FreeText annotations
This commit is contained in:
commit
64520a0c63
@ -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),
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user