[Editor] Don't add an editor for empty FreeText annotations
This commit is contained in:
parent
5581e22cc7
commit
1ab34d2ae4
@ -539,6 +539,10 @@ class FreeTextEditor extends AnnotationEditor {
|
|||||||
textContent,
|
textContent,
|
||||||
page: { pageNumber },
|
page: { pageNumber },
|
||||||
} = data;
|
} = data;
|
||||||
|
if (!textContent || textContent.length === 0) {
|
||||||
|
// Empty annotation.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
initialData = data = {
|
initialData = data = {
|
||||||
annotationType: AnnotationEditorType.FREETEXT,
|
annotationType: AnnotationEditorType.FREETEXT,
|
||||||
color: Array.from(fontColor),
|
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)", () => {
|
describe("FreeText (delete existing)", () => {
|
||||||
let pages;
|
let pages;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user