1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Merge pull request #19506 from calixteman/bug1948741

[Editor] Scale the signature editor when it's too large (bug 1948741)
This commit is contained in:
calixteman 2025-02-17 21:59:46 +01:00 committed by GitHub
commit d0107566ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 0 deletions

View file

@ -248,6 +248,11 @@ class SignatureEditor extends DrawingEditor {
newHeight = newHeight >= 1 ? 0.5 : newHeight;
this.width *= newHeight / this.height;
if (this.width >= 1) {
newHeight *= 0.9 / this.width;
this.width = 0.9;
}
this.height = newHeight;
this.setDims(parentWidth * this.width, parentHeight * this.height);
this.x = savedX;

View file

@ -16,6 +16,7 @@
import {
closePages,
getEditorSelector,
getRect,
loadAndWait,
switchToEditor,
waitForTimeout,
@ -207,4 +208,46 @@ describe("Signature Editor", () => {
);
});
});
describe("Bug 1948741", () => {
let pages;
beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
});
afterEach(async () => {
await closePages(pages);
});
it("must check that the editor isn't too large", async () => {
await Promise.all(
pages.map(async ([_, page]) => {
await switchToSignature(page);
await page.click("#editorSignatureAddSignature");
await page.waitForSelector("#addSignatureDialog", {
visible: true,
});
await page.type(
"#addSignatureTypeInput",
"[18:50:03] asset pdf.scripting.mjs 105 KiB [emitted] [javascript module] (name: main)"
);
await page.waitForSelector(`${addButtonSelector}:not(:disabled)`);
await page.click("#addSignatureAddButton");
const editorSelector = getEditorSelector(0);
await page.waitForSelector(editorSelector, { visible: true });
await page.waitForSelector(
`.canvasWrapper > svg use[href="#path_p1_0"]`,
{ visible: true }
);
const { width } = await getRect(page, editorSelector);
const { width: pageWidth } = await getRect(page, ".page");
expect(width).toBeLessThanOrEqual(pageWidth);
})
);
});
});
});