mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-05-31 07:11:00 +02:00
Merge pull request #21196 from calixteman/bug2035530
Fix free highlight on pages without images (bug 2035530)
This commit is contained in:
commit
7ebf3a4d7c
@ -466,6 +466,7 @@ class AnnotationEditorLayer {
|
||||
target === this.#textLayer.div ||
|
||||
((target.getAttribute("role") === "img" ||
|
||||
target.classList.contains("endOfContent") ||
|
||||
target.classList.contains("textLayerImages") ||
|
||||
target.classList.contains("textLayerImagePlaceholder")) &&
|
||||
this.#textLayer.div.contains(target))
|
||||
) {
|
||||
|
||||
@ -347,4 +347,53 @@ describe("Text layer images", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("free-highlighting on a page with no images", () => {
|
||||
let pages;
|
||||
|
||||
beforeEach(async () => {
|
||||
pages = await loadAndWait(
|
||||
"empty.pdf",
|
||||
`.page[data-page-number = "1"] .textLayerImages`,
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
imagesRightClickMinSize: 16,
|
||||
highlightEditorColors: "yellow=#FFFF00",
|
||||
},
|
||||
{ width: 800, height: 600, devicePixelRatio: 1 }
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must create a free highlight when dragging on the empty image container", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await switchToHighlight(page);
|
||||
|
||||
const rect = await getRect(
|
||||
page,
|
||||
`.page[data-page-number="1"] > .textLayer > .textLayerImages`
|
||||
);
|
||||
|
||||
const x1 = rect.x + rect.width / 4;
|
||||
const y1 = rect.y + rect.height / 4;
|
||||
const x2 = rect.x + (3 * rect.width) / 4;
|
||||
const y2 = rect.y + (3 * rect.height) / 4;
|
||||
|
||||
const clickHandle = await waitForPointerUp(page);
|
||||
await page.mouse.move(x1, y1);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x2, y2);
|
||||
await page.mouse.up();
|
||||
await awaitPromise(clickHandle);
|
||||
|
||||
await page.waitForSelector(getEditorSelector(0));
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -323,7 +323,7 @@ const defaultOptions = {
|
||||
imagesRightClickMinSize: {
|
||||
/** @type {number} */
|
||||
value:
|
||||
typeof PDFJSDev !== "undefined" &&
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
// Firefox mobile does not support right-clicking on images,
|
||||
// see https://bugzilla.mozilla.org/show_bug.cgi?id=2014081.
|
||||
// This option is disabled by default outside of MOZCENTRAL
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user