mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
[Editor] Refactor dragging and dropping an editor (bugs 1802895, 1844618)
It'll help to have a full control on what's happening when moving an editor.
This commit is contained in:
parent
0725b6299f
commit
b59b1a81a9
11 changed files with 170 additions and 75 deletions
|
@ -15,6 +15,7 @@
|
|||
|
||||
const {
|
||||
closePages,
|
||||
dragAndDropAnnotation,
|
||||
getEditors,
|
||||
getEditorSelector,
|
||||
getSelectedEditors,
|
||||
|
@ -891,13 +892,6 @@ describe("FreeText Editor", () => {
|
|||
it("must move an annotation", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
if (browserName === "firefox") {
|
||||
pending(
|
||||
"Disabled in Firefox, because DnD isn't implemented yet (see bug 1838638)."
|
||||
);
|
||||
}
|
||||
|
||||
await page.setDragInterception(true);
|
||||
await page.click("#editorFreeText");
|
||||
|
||||
const editorIds = await getEditors(page, "freeText");
|
||||
|
@ -913,16 +907,12 @@ describe("FreeText Editor", () => {
|
|||
return { x, y, width, height };
|
||||
});
|
||||
|
||||
await page.mouse.dragAndDrop(
|
||||
{
|
||||
x: editorRect.x + editorRect.width / 2,
|
||||
y: editorRect.y + editorRect.height / 2,
|
||||
},
|
||||
{
|
||||
x: editorRect.x + editorRect.width / 2 + 100,
|
||||
y: editorRect.y + editorRect.height / 2 + 100,
|
||||
},
|
||||
{ delay: 100 }
|
||||
await dragAndDropAnnotation(
|
||||
page,
|
||||
editorRect.x + editorRect.width / 2,
|
||||
editorRect.y + editorRect.height / 2,
|
||||
100,
|
||||
100
|
||||
);
|
||||
|
||||
serialized = await getSerialized(page);
|
||||
|
|
|
@ -194,3 +194,11 @@ function serializeBitmapDimensions(page) {
|
|||
});
|
||||
}
|
||||
exports.serializeBitmapDimensions = serializeBitmapDimensions;
|
||||
|
||||
async function dragAndDropAnnotation(page, startX, startY, tX, tY) {
|
||||
await page.mouse.move(startX, startY);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(startX + tX, startY + tY);
|
||||
await page.mouse.up();
|
||||
}
|
||||
exports.dragAndDropAnnotation = dragAndDropAnnotation;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue