mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-24 09:08:07 +02:00
Merge pull request #19309 from calixteman/make_unique_id_draw_layer
[Editor] Set a unique id for each element in the draw layer
This commit is contained in:
commit
f1166f480f
3 changed files with 75 additions and 6 deletions
|
@ -1015,4 +1015,73 @@ describe("Ink Editor", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Draw annotations on several page, move one of them and delete it", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait(
|
||||
"tracemonkey.pdf",
|
||||
".annotationEditorLayer",
|
||||
10
|
||||
);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check that the first annotation is correctly associated with its SVG", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await switchToInk(page);
|
||||
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const pageSelector = `.page[data-page-number = "${i + 1}"]`;
|
||||
const rect = await getRect(
|
||||
page,
|
||||
`${pageSelector} .annotationEditorLayer`
|
||||
);
|
||||
const xStart = rect.x + 10;
|
||||
const yStart = rect.y + 10;
|
||||
const clickHandle = await waitForPointerUp(page);
|
||||
await page.mouse.move(xStart, yStart);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(xStart + 10, yStart + 10);
|
||||
await page.mouse.up();
|
||||
await awaitPromise(clickHandle);
|
||||
await commit(page);
|
||||
}
|
||||
|
||||
const pageOneSelector = `.page[data-page-number = "1"]`;
|
||||
const initialRect = await getRect(page, `${pageOneSelector} svg`);
|
||||
|
||||
let editorSelector = getEditorSelector(1);
|
||||
await waitForSelectedEditor(page, editorSelector);
|
||||
await dragAndDrop(page, editorSelector, [[0, -30]], /* steps = */ 10);
|
||||
await waitForSerialized(page, 2);
|
||||
await page.waitForSelector(`${editorSelector} button.delete`);
|
||||
await page.click(`${editorSelector} button.delete`);
|
||||
await waitForSerialized(page, 1);
|
||||
await page.click("#editorUndoBarUndoButton");
|
||||
await page.waitForSelector("#editorUndoBar", { hidden: true });
|
||||
|
||||
editorSelector = getEditorSelector(0);
|
||||
const editorRect = await getRect(page, editorSelector);
|
||||
await page.mouse.click(
|
||||
editorRect.x + editorRect.width / 2,
|
||||
editorRect.y + editorRect.height / 2
|
||||
);
|
||||
await waitForSelectedEditor(page, editorSelector);
|
||||
|
||||
await dragAndDrop(page, editorSelector, [[30, 30]], /* steps = */ 10);
|
||||
const finalRect = await getRect(page, `${pageOneSelector} svg`);
|
||||
|
||||
expect(initialRect)
|
||||
.withContext(`In ${browserName}`)
|
||||
.not.toEqual(finalRect);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -511,14 +511,14 @@ async function serializeBitmapDimensions(page) {
|
|||
});
|
||||
}
|
||||
|
||||
async function dragAndDrop(page, selector, translations) {
|
||||
async function dragAndDrop(page, selector, translations, steps = 1) {
|
||||
const rect = await getRect(page, selector);
|
||||
const startX = rect.x + rect.width / 2;
|
||||
const startY = rect.y + rect.height / 2;
|
||||
await page.mouse.move(startX, startY);
|
||||
await page.mouse.down();
|
||||
for (const [tX, tY] of translations) {
|
||||
await page.mouse.move(startX + tX, startY + tY);
|
||||
await page.mouse.move(startX + tX, startY + tY, { steps });
|
||||
}
|
||||
await page.mouse.up();
|
||||
await page.waitForSelector("#viewer:not(.noUserSelect)");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue