1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

[Editor] Allow to abort the current drawing

It fixes #19126.
This commit is contained in:
Calixte Denizet 2024-11-29 16:22:44 +01:00
parent 308ca2a16f
commit 4acc086292
5 changed files with 91 additions and 21 deletions

View file

@ -26,6 +26,7 @@ import {
loadAndWait,
scrollIntoView,
switchToEditor,
waitForNoElement,
waitForSerialized,
waitForStorageEntries,
} from "./test_utils.mjs";
@ -567,4 +568,48 @@ describe("Ink Editor", () => {
);
});
});
describe("Can delete the drawing in progress and undo the deletion", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterAll(async () => {
await closePages(pages);
});
it("must check that the color has been changed", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await switchToInk(page);
const rect = await getRect(page, ".annotationEditorLayer");
const x = rect.x + 20;
const y = rect.y + 20;
const clickHandle = await waitForPointerUp(page);
await page.mouse.move(x, y);
await page.mouse.down();
await page.mouse.move(x + 50, y + 50);
await page.mouse.up();
await awaitPromise(clickHandle);
const drawSelector = `.canvasWrapper svg.draw path[d]:not([d=""])`;
await page.waitForSelector(drawSelector);
await page.keyboard.press("Backspace");
const editorSelector = getEditorSelector(0);
await waitForNoElement(page, drawSelector);
await waitForNoElement(page, editorSelector);
await kbUndo(page);
await page.waitForSelector(editorSelector, { visible: true });
await page.waitForSelector(drawSelector);
})
);
});
});
});

View file

@ -773,6 +773,14 @@ async function switchToEditor(name, page, disable = false) {
await awaitPromise(modeChangedHandle);
}
function waitForNoElement(page, selector) {
return page.waitForFunction(
sel => !document.querySelector(sel),
{},
selector
);
}
export {
applyFunctionToEditor,
awaitPromise,
@ -826,6 +834,7 @@ export {
waitForAnnotationModeChanged,
waitForEntryInStorage,
waitForEvent,
waitForNoElement,
waitForPageRendered,
waitForSandboxTrip,
waitForSelectedEditor,