Skip to content

Commit 464dae1

Browse files
committed
fix: deleteAnnotationElement takes a full editor object
1 parent 8f0c629 commit 464dae1

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

src/display/editor/annotation_editor_layer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ class AnnotationEditorLayer {
561561
}
562562

563563
if (editor.parent && editor.annotationElementId) {
564-
this.#uiManager.addDeletedAnnotationElement(editor.annotationElementId);
564+
this.#uiManager.addDeletedAnnotationElement(editor);
565565
AnnotationEditor.deleteAnnotationElement(editor);
566566
editor.annotationElementId = null;
567567
}

test/integration/stamp_editor_spec.mjs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,4 +1824,71 @@ describe("Stamp Editor", () => {
18241824
);
18251825
});
18261826
});
1827+
1828+
describe("Stamp (move between pages)", () => {
1829+
let pages;
1830+
1831+
beforeEach(async () => {
1832+
pages = await loadAndWait(
1833+
"firefox_stamp.pdf",
1834+
getAnnotationSelector("24R"),
1835+
"50"
1836+
);
1837+
});
1838+
1839+
afterEach(async () => {
1840+
await closePages(pages);
1841+
});
1842+
1843+
it("must move a stamp annotation from page 1 to page 2", async () => {
1844+
await Promise.all(
1845+
pages.map(async ([browserName, page]) => {
1846+
await waitForPageRendered(page, 1);
1847+
await waitForPageRendered(page, 2);
1848+
await waitForAnnotationEditorLayer(page, 1);
1849+
await waitForAnnotationEditorLayer(page, 2);
1850+
1851+
const modeChangedHandle = await waitForAnnotationModeChanged(page);
1852+
1853+
await page.click(getAnnotationSelector("24R"), { count: 2 });
1854+
await awaitPromise(modeChangedHandle);
1855+
1856+
const editorSelector = getEditorSelector(0);
1857+
await waitForSelectedEditor(page, editorSelector);
1858+
1859+
await scrollIntoView(
1860+
page,
1861+
`.page[data-page-number="2"] .annotationEditorLayer`
1862+
);
1863+
1864+
const editorRect = await getRect(page, editorSelector);
1865+
const page2Rect = await getRect(
1866+
page,
1867+
`.page[data-page-number="2"] .annotationEditorLayer`
1868+
);
1869+
1870+
const deltaX =
1871+
page2Rect.x +
1872+
page2Rect.width / 2 -
1873+
(editorRect.x + editorRect.width / 2);
1874+
const deltaY =
1875+
page2Rect.y +
1876+
page2Rect.height / 3 -
1877+
(editorRect.y + editorRect.height / 2);
1878+
1879+
await dragAndDrop(page, editorSelector, [[deltaX, deltaY]], 10);
1880+
1881+
await page.waitForFunction(
1882+
sel => {
1883+
const editorDiv = document.querySelector(sel);
1884+
const pageDiv = editorDiv?.closest(".page");
1885+
return pageDiv?.getAttribute("data-page-number") === "2";
1886+
},
1887+
{},
1888+
editorSelector
1889+
);
1890+
})
1891+
);
1892+
});
1893+
});
18271894
});

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@
732732
!bug1885505.pdf
733733
!bug1974436.pdf
734734
!firefox_logo.pdf
735+
!firefox_stamp.pdf
735736
!issue20062.pdf
736737
!issue20102.pdf
737738
!issue20065.pdf

test/pdfs/firefox_stamp.pdf

47.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)