Skip to content

Commit 7e5b36c

Browse files
authored
Merge pull request #21171 from calixteman/bug2034980
Allow free-highlighting on top of image placeholders (bug 2034980)
2 parents 01b315a + dc3c07b commit 7e5b36c

2 files changed

Lines changed: 64 additions & 2 deletions

File tree

src/display/editor/annotation_editor_layer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@ class AnnotationEditorLayer {
465465
if (
466466
target === this.#textLayer.div ||
467467
((target.getAttribute("role") === "img" ||
468-
target.classList.contains("endOfContent")) &&
468+
target.classList.contains("endOfContent") ||
469+
target.classList.contains("textLayerImagePlaceholder")) &&
469470
this.#textLayer.div.contains(target))
470471
) {
471472
const { isMac } = FeatureTest.platform;

test/integration/text_layer_images_spec.mjs

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@
1313
* limitations under the License.
1414
*/
1515

16-
import { closePages, loadAndWait } from "./test_utils.mjs";
16+
import {
17+
awaitPromise,
18+
closePages,
19+
getEditorSelector,
20+
getRect,
21+
loadAndWait,
22+
switchToEditor,
23+
waitForPointerUp,
24+
} from "./test_utils.mjs";
25+
26+
const switchToHighlight = switchToEditor.bind(null, "Highlight");
1727

1828
describe("Text layer images", () => {
1929
describe("basic", () => {
@@ -286,4 +296,55 @@ describe("Text layer images", () => {
286296
);
287297
});
288298
});
299+
300+
describe("free-highlighting on top of an image placeholder", () => {
301+
let pages;
302+
303+
beforeEach(async () => {
304+
pages = await loadAndWait(
305+
"images.pdf",
306+
`.page[data-page-number = "1"] .endOfContent`,
307+
undefined,
308+
{
309+
earlySetup: `() => { window.devicePixelRatio = 1 }`,
310+
},
311+
{
312+
imagesRightClickMinSize: 16,
313+
highlightEditorColors: "yellow=#FFFF00",
314+
},
315+
{ width: 800, height: 600, devicePixelRatio: 1 }
316+
);
317+
});
318+
319+
afterEach(async () => {
320+
await closePages(pages);
321+
});
322+
323+
it("must create a free highlight when dragging on an image placeholder (bug 2034980)", async () => {
324+
await Promise.all(
325+
pages.map(async ([browserName, page]) => {
326+
await switchToHighlight(page);
327+
328+
const rect = await getRect(
329+
page,
330+
`.page[data-page-number="1"] > .textLayer > .textLayerImages > canvas`
331+
);
332+
333+
const x1 = rect.x + rect.width / 4;
334+
const y1 = rect.y + rect.height / 4;
335+
const x2 = rect.x + (3 * rect.width) / 4;
336+
const y2 = rect.y + (3 * rect.height) / 4;
337+
338+
const clickHandle = await waitForPointerUp(page);
339+
await page.mouse.move(x1, y1);
340+
await page.mouse.down();
341+
await page.mouse.move(x2, y2);
342+
await page.mouse.up();
343+
await awaitPromise(clickHandle);
344+
345+
await page.waitForSelector(getEditorSelector(0));
346+
})
347+
);
348+
});
349+
});
289350
});

0 commit comments

Comments
 (0)