Skip to content

Commit

Permalink
[Editor] Show hidden annotations once editing is finished
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Jun 19, 2023
1 parent 04c31a5 commit ae3cee9
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/display/editor/annotation_editor_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,32 @@ class AnnotationEditorLayer {
disable() {
this.#isDisabling = true;
this.div.style.pointerEvents = "none";
const hiddenAnnotationIds = new Set();
for (const editor of this.#editors.values()) {
editor.disableEditing();
if (!editor.annotationElementId || editor.serialize() !== null) {
hiddenAnnotationIds.add(editor.annotationElementId);
continue;
}
this.getEditableAnnotation(editor.annotationElementId)?.show();
editor.remove();
}

if (this.#annotationLayer) {
// Show the annotations that were hidden in enable().
const editables = this.#annotationLayer.getEditableAnnotations();
for (const editable of editables) {
const { id } = editable.data;
if (
hiddenAnnotationIds.has(id) ||
this.#uiManager.isDeletedAnnotationElement(id)
) {
continue;
}
editable.show();
}
}

this.#cleanup();
if (this.isEmpty) {
this.div.hidden = true;
Expand Down
37 changes: 37 additions & 0 deletions test/integration/annotation_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,41 @@ describe("ResetForm action", () => {
});
});
});

describe("Ink widget and its popup after editing", () => {
describe("annotation-caret-ink.pdf", () => {
let pages;

beforeAll(async () => {
pages = await loadAndWait(
"annotation-caret-ink.pdf",
"[data-annotation-id='25R']"
);
});

afterAll(async () => {
await closePages(pages);
});

it("must check that the annotation has a popup", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForFunction(
`document.querySelector("[data-annotation-id='25R']").hidden === false`
);
await page.click("#editorFreeText");
await page.waitForTimeout(10);
await page.waitForFunction(
`document.querySelector("[data-annotation-id='25R']").hidden === true`
);
await page.click("#editorFreeText");
await page.waitForTimeout(10);
await page.waitForFunction(
`document.querySelector("[data-annotation-id='25R']").hidden === false`
);
})
);
});
});
});
});

0 comments on commit ae3cee9

Please sign in to comment.