Skip to content

Commit 35b604b

Browse files
authored
Merge pull request #20011 from calixteman/bug1971134
[Editor] Fix the text alignment in freetext annotations (bug 1971134)
2 parents 802808c + 8d7246a commit 35b604b

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

test/integration/freetext_editor_spec.mjs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,4 +3309,52 @@ describe("FreeText Editor", () => {
33093309
);
33103310
});
33113311
});
3312+
3313+
describe("Freetext and text alignment", () => {
3314+
let pages;
3315+
3316+
beforeEach(async () => {
3317+
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
3318+
});
3319+
3320+
afterEach(async () => {
3321+
await closePages(pages);
3322+
});
3323+
3324+
it("must check that the alignment is correct", async () => {
3325+
await Promise.all(
3326+
pages.map(async ([browserName, page]) => {
3327+
await switchToFreeText(page);
3328+
3329+
const rect = await getRect(page, ".annotationEditorLayer");
3330+
const editorSelector = getEditorSelector(0);
3331+
3332+
const data = "Hello PDF.js World !!";
3333+
await page.mouse.click(rect.x + 100, rect.y + 100);
3334+
await page.waitForSelector(editorSelector, { visible: true });
3335+
await page.type(`${editorSelector} .internal`, data);
3336+
await commit(page);
3337+
await waitForSerialized(page, 1);
3338+
3339+
let alignment = await page.$eval(
3340+
`${editorSelector} .internal`,
3341+
el => getComputedStyle(el).textAlign
3342+
);
3343+
expect(alignment).withContext(`In ${browserName}`).toEqual("start");
3344+
3345+
await page.click("#secondaryToolbarToggleButton");
3346+
await page.waitForSelector("#secondaryToolbar", { visible: true });
3347+
await page.click("#spreadOdd");
3348+
await page.waitForSelector("#secondaryToolbar", { visible: false });
3349+
await page.waitForSelector(".spread");
3350+
3351+
alignment = await page.$eval(
3352+
`${editorSelector} .internal`,
3353+
el => getComputedStyle(el).textAlign
3354+
);
3355+
expect(alignment).withContext(`In ${browserName}`).toEqual("start");
3356+
})
3357+
);
3358+
});
3359+
});
33123360
});

web/annotation_editor_layer_builder.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@
517517
white-space: nowrap;
518518
font: 10px sans-serif;
519519
line-height: var(--freetext-line-height);
520+
text-align: start;
520521
user-select: none;
521522
}
522523

0 commit comments

Comments
 (0)