mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
[Editor] When deleting an annotation with popup, then delete the popup too
This commit is contained in:
parent
3902a148e2
commit
0382dd0e25
9 changed files with 104 additions and 25 deletions
|
@ -1237,6 +1237,7 @@ describe("FreeText Editor", () => {
|
|||
pageIndex: 0,
|
||||
id: "51R",
|
||||
deleted: true,
|
||||
popupRef: "",
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
|
@ -1972,6 +1972,50 @@ describe("Highlight Editor", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Highlight (delete an existing annotation)", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait(
|
||||
"highlight_popup.pdf",
|
||||
".annotationEditorLayer"
|
||||
);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must delete an existing annotation and its popup", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
const modeChangedHandle = await waitForAnnotationModeChanged(page);
|
||||
await waitAndClick(page, "[data-annotation-id='24R']", { count: 2 });
|
||||
await awaitPromise(modeChangedHandle);
|
||||
await page.waitForSelector("#highlightParamsToolbarContainer");
|
||||
|
||||
const editorSelector = getEditorSelector(0);
|
||||
await page.waitForSelector(editorSelector);
|
||||
await page.waitForSelector(`${editorSelector} button.delete`);
|
||||
await page.click(`${editorSelector} button.delete`);
|
||||
await waitForSerialized(page, 1);
|
||||
|
||||
const serialized = await getSerialized(page);
|
||||
expect(serialized)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual([
|
||||
{
|
||||
pageIndex: 0,
|
||||
id: "24R",
|
||||
deleted: true,
|
||||
popupRef: "25R",
|
||||
},
|
||||
]);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Free Highlight (edit existing in double clicking on it)", () => {
|
||||
let pages;
|
||||
|
||||
|
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -670,3 +670,4 @@
|
|||
!bug1918115.pdf
|
||||
!bug1919513.pdf
|
||||
!issue16038.pdf
|
||||
!highlight_popup.pdf
|
||||
|
|
BIN
test/pdfs/highlight_popup.pdf
Executable file
BIN
test/pdfs/highlight_popup.pdf
Executable file
Binary file not shown.
|
@ -2926,6 +2926,29 @@ describe("api", function () {
|
|||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("write an highlight annotation and delete its popup", async function () {
|
||||
let loadingTask = getDocument(
|
||||
buildGetDocumentParams("highlight_popup.pdf")
|
||||
);
|
||||
let pdfDoc = await loadingTask.promise;
|
||||
pdfDoc.annotationStorage.setValue("pdfjs_internal_editor_0", {
|
||||
deleted: true,
|
||||
id: "24R",
|
||||
pageIndex: 0,
|
||||
popupRef: "25R",
|
||||
});
|
||||
const data = await pdfDoc.saveDocument();
|
||||
await loadingTask.destroy();
|
||||
|
||||
loadingTask = getDocument(data);
|
||||
pdfDoc = await loadingTask.promise;
|
||||
const page = await pdfDoc.getPage(1);
|
||||
const annotations = await page.getAnnotations();
|
||||
|
||||
expect(annotations).toEqual([]);
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("read content from multiline textfield containing an empty line", async function () {
|
||||
const loadingTask = getDocument(buildGetDocumentParams("issue17492.pdf"));
|
||||
const pdfDoc = await loadingTask.promise;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue