diff --git a/src/display/editor/highlight.js b/src/display/editor/highlight.js index 70db98849d2d3..180f172529505 100644 --- a/src/display/editor/highlight.js +++ b/src/display/editor/highlight.js @@ -109,6 +109,9 @@ class HighlightEditor extends AnnotationEditor { } } + /** @inheritdoc */ + translateInPage(x, y) {} + /** @inheritdoc */ get toolbarPosition() { return this.#lastPoint; diff --git a/test/integration/highlight_editor_spec.mjs b/test/integration/highlight_editor_spec.mjs index 61f8dd9cd2e61..e8e39bf6b0d95 100644 --- a/test/integration/highlight_editor_spec.mjs +++ b/test/integration/highlight_editor_spec.mjs @@ -17,6 +17,8 @@ import { closePages, getEditorSelector, getSerialized, + kbBigMoveLeft, + kbBigMoveUp, kbSelectAll, loadAndWait, scrollIntoView, @@ -30,6 +32,12 @@ const selectAll = async page => { ); }; +const getXY = (page, selector) => + page.evaluate(sel => { + const bbox = document.querySelector(sel).getBoundingClientRect(); + return `${bbox.x}::${bbox.y}`; + }, selector); + const getSpanRectFromText = (page, pageNumber, text) => { return page.evaluate( (number, content) => { @@ -352,7 +360,7 @@ describe("Highlight Editor", () => { await closePages(pages); }); - it("must be correctly serialized", async () => { + it("must check that we can use the keyboard to select a color", async () => { await Promise.all( pages.map(async ([browserName, page]) => { await page.click("#editorHighlight"); @@ -427,4 +435,57 @@ describe("Highlight Editor", () => { ); }); }); + + describe("Text highlights aren't draggable", () => { + let pages; + + beforeAll(async () => { + pages = await loadAndWait( + "tracemonkey.pdf", + ".annotationEditorLayer", + null, + null, + { highlightEditorColors: "red=#AB0000" } + ); + }); + + afterAll(async () => { + await closePages(pages); + }); + + it("must check that a text highlight don't move when arrows are pressed", async () => { + await Promise.all( + pages.map(async ([browserName, page]) => { + await page.click("#editorHighlight"); + await page.waitForSelector(".annotationEditorLayer.highlightEditing"); + + const rect = await getSpanRectFromText(page, 1, "Abstract"); + const x = rect.x + rect.width / 2; + const y = rect.y + rect.height / 2; + await page.mouse.click(x, y, { count: 2 }); + + await page.waitForSelector(`${getEditorSelector(0)}`); + await page.waitForSelector( + `.page[data-page-number = "1"] svg.highlightOutline.selected` + ); + await page.focus(getEditorSelector(0)); + + const xy = await getXY(page, getEditorSelector(0)); + for (let i = 0; i < 5; i++) { + await kbBigMoveLeft(page); + } + expect(await getXY(page, getEditorSelector(0))) + .withContext(`In ${browserName}`) + .toEqual(xy); + + for (let i = 0; i < 5; i++) { + await kbBigMoveUp(page); + } + expect(await getXY(page, getEditorSelector(0))) + .withContext(`In ${browserName}`) + .toEqual(xy); + }) + ); + }); + }); });