mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
[Editor] Add a button to explicitly add an image (bug 1848108)
The main stamp button will be used to just enter in a add/edit image mode: - the user can add a new image in using the new button. - the user can edit an image in resizing, moving it. In image mode, when the user clicks outside on the page but not on an editor, then all the selected editors will be unselected.
This commit is contained in:
parent
d57e3ebbe4
commit
659fbc5020
13 changed files with 140 additions and 34 deletions
|
@ -15,7 +15,9 @@
|
|||
|
||||
const {
|
||||
closePages,
|
||||
dragAndDropAnnotation,
|
||||
getEditorDimensions,
|
||||
getEditorSelector,
|
||||
loadAndWait,
|
||||
serializeBitmapDimensions,
|
||||
waitForAnnotationEditorLayer,
|
||||
|
@ -43,15 +45,8 @@ describe("Stamp Editor", () => {
|
|||
}
|
||||
|
||||
await page.click("#editorStamp");
|
||||
await page.click("#editorStampAddImage");
|
||||
|
||||
const rect = await page.$eval(".annotationEditorLayer", el => {
|
||||
// With Chrome something is wrong when serializing a DomRect,
|
||||
// hence we extract the values and just return them.
|
||||
const { x, y } = el.getBoundingClientRect();
|
||||
return { x, y };
|
||||
});
|
||||
|
||||
await page.mouse.click(rect.x + 100, rect.y + 100);
|
||||
const input = await page.$("#stampEditorFileInput");
|
||||
await input.uploadFile(
|
||||
`${path.join(__dirname, "../images/firefox_logo.png")}`
|
||||
|
@ -87,14 +82,7 @@ describe("Stamp Editor", () => {
|
|||
return;
|
||||
}
|
||||
|
||||
const rect = await page.$eval(".annotationEditorLayer", el => {
|
||||
// With Chrome something is wrong when serializing a DomRect,
|
||||
// hence we extract the values and just return them.
|
||||
const { x, y } = el.getBoundingClientRect();
|
||||
return { x, y };
|
||||
});
|
||||
|
||||
await page.mouse.click(rect.x + 100, rect.y + 100);
|
||||
await page.click("#editorStampAddImage");
|
||||
const input = await page.$("#stampEditorFileInput");
|
||||
await input.uploadFile(
|
||||
`${path.join(__dirname, "../images/firefox_logo.svg")}`
|
||||
|
@ -146,6 +134,7 @@ describe("Stamp Editor", () => {
|
|||
}
|
||||
|
||||
await page.click("#editorStamp");
|
||||
await page.click("#editorStampAddImage");
|
||||
|
||||
const rect = await page.$eval(".annotationEditorLayer", el => {
|
||||
// With Chrome something is wrong when serializing a DomRect,
|
||||
|
@ -154,7 +143,13 @@ describe("Stamp Editor", () => {
|
|||
return { x: right, y: bottom };
|
||||
});
|
||||
|
||||
await page.mouse.click(rect.x - 10, rect.y - 10);
|
||||
const editorRect = await page.$eval(getEditorSelector(0), el => {
|
||||
// With Chrome something is wrong when serializing a DomRect,
|
||||
// hence we extract the values and just return them.
|
||||
const { x, y } = el.getBoundingClientRect();
|
||||
return { x, y };
|
||||
});
|
||||
|
||||
const input = await page.$("#stampEditorFileInput");
|
||||
await input.uploadFile(
|
||||
`${path.join(__dirname, "../images/firefox_logo.png")}`
|
||||
|
@ -162,6 +157,15 @@ describe("Stamp Editor", () => {
|
|||
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
await dragAndDropAnnotation(
|
||||
page,
|
||||
editorRect.x + 10,
|
||||
editorRect.y + 10,
|
||||
rect.x - 10,
|
||||
rect.y - 10
|
||||
);
|
||||
await page.waitForTimeout(10);
|
||||
|
||||
const { left } = await getEditorDimensions(page, 0);
|
||||
|
||||
// The image is bigger than the page, so it has been scaled down to
|
||||
|
@ -204,14 +208,7 @@ describe("Stamp Editor", () => {
|
|||
await page.waitForTimeout(10);
|
||||
}
|
||||
|
||||
const rect = await page.$eval(".annotationEditorLayer", el => {
|
||||
// With Chrome something is wrong when serializing a DomRect,
|
||||
// hence we extract the values and just return them.
|
||||
const { x, y } = el.getBoundingClientRect();
|
||||
return { x, y };
|
||||
});
|
||||
|
||||
await page.mouse.click(rect.x + 10, rect.y + 10);
|
||||
await page.click("#editorStampAddImage");
|
||||
await page.waitForTimeout(10);
|
||||
const input = await page.$("#stampEditorFileInput");
|
||||
await input.uploadFile(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue