mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
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
2 changed files with 27 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue