diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index fe472bca0..32fd60436 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -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)) ) { diff --git a/test/integration/text_layer_images_spec.mjs b/test/integration/text_layer_images_spec.mjs index fd7342c2f..cc8fe8416 100644 --- a/test/integration/text_layer_images_spec.mjs +++ b/test/integration/text_layer_images_spec.mjs @@ -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)); + }) + ); + }); + }); }); diff --git a/web/app_options.js b/web/app_options.js index d84ba9336..06b9b3dc5 100644 --- a/web/app_options.js +++ b/web/app_options.js @@ -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