diff --git a/.playwright/screenshots/ellipsize-between-empty-paragraphs-clip.png b/.playwright/screenshots/ellipsize-between-empty-paragraphs-clip.png new file mode 100644 index 00000000..f36c8d91 Binary files /dev/null and b/.playwright/screenshots/ellipsize-between-empty-paragraphs-clip.png differ diff --git a/.playwright/screenshots/ellipsize-between-empty-paragraphs-head.png b/.playwright/screenshots/ellipsize-between-empty-paragraphs-head.png new file mode 100644 index 00000000..fa5cd6c4 Binary files /dev/null and b/.playwright/screenshots/ellipsize-between-empty-paragraphs-head.png differ diff --git a/.playwright/screenshots/ellipsize-between-empty-paragraphs-tail.png b/.playwright/screenshots/ellipsize-between-empty-paragraphs-tail.png new file mode 100644 index 00000000..2c2708c0 Binary files /dev/null and b/.playwright/screenshots/ellipsize-between-empty-paragraphs-tail.png differ diff --git a/.playwright/screenshots/ellipsize-between-multiple-empty-lines-clip.png b/.playwright/screenshots/ellipsize-between-multiple-empty-lines-clip.png new file mode 100644 index 00000000..ff283877 Binary files /dev/null and b/.playwright/screenshots/ellipsize-between-multiple-empty-lines-clip.png differ diff --git a/.playwright/screenshots/ellipsize-between-multiple-empty-lines-head.png b/.playwright/screenshots/ellipsize-between-multiple-empty-lines-head.png new file mode 100644 index 00000000..fa5cd6c4 Binary files /dev/null and b/.playwright/screenshots/ellipsize-between-multiple-empty-lines-head.png differ diff --git a/.playwright/screenshots/ellipsize-between-multiple-empty-lines-tail.png b/.playwright/screenshots/ellipsize-between-multiple-empty-lines-tail.png new file mode 100644 index 00000000..fa5cd6c4 Binary files /dev/null and b/.playwright/screenshots/ellipsize-between-multiple-empty-lines-tail.png differ diff --git a/.playwright/screenshots/ellipsize-checkbox-list-clip.png b/.playwright/screenshots/ellipsize-checkbox-list-clip.png new file mode 100644 index 00000000..85317e34 Binary files /dev/null and b/.playwright/screenshots/ellipsize-checkbox-list-clip.png differ diff --git a/.playwright/screenshots/ellipsize-checkbox-list-head.png b/.playwright/screenshots/ellipsize-checkbox-list-head.png new file mode 100644 index 00000000..147bb001 Binary files /dev/null and b/.playwright/screenshots/ellipsize-checkbox-list-head.png differ diff --git a/.playwright/screenshots/ellipsize-checkbox-list-only-empty-clip.png b/.playwright/screenshots/ellipsize-checkbox-list-only-empty-clip.png new file mode 100644 index 00000000..be82fe76 Binary files /dev/null and b/.playwright/screenshots/ellipsize-checkbox-list-only-empty-clip.png differ diff --git a/.playwright/screenshots/ellipsize-checkbox-list-only-empty-head.png b/.playwright/screenshots/ellipsize-checkbox-list-only-empty-head.png new file mode 100644 index 00000000..d38b3ee0 Binary files /dev/null and b/.playwright/screenshots/ellipsize-checkbox-list-only-empty-head.png differ diff --git a/.playwright/screenshots/ellipsize-checkbox-list-only-empty-tail.png b/.playwright/screenshots/ellipsize-checkbox-list-only-empty-tail.png new file mode 100644 index 00000000..d38b3ee0 Binary files /dev/null and b/.playwright/screenshots/ellipsize-checkbox-list-only-empty-tail.png differ diff --git a/.playwright/screenshots/ellipsize-checkbox-list-tail.png b/.playwright/screenshots/ellipsize-checkbox-list-tail.png new file mode 100644 index 00000000..a17743c1 Binary files /dev/null and b/.playwright/screenshots/ellipsize-checkbox-list-tail.png differ diff --git a/.playwright/screenshots/ellipsize-checkbox-list-with-empty-clip.png b/.playwright/screenshots/ellipsize-checkbox-list-with-empty-clip.png new file mode 100644 index 00000000..23dc9d3e Binary files /dev/null and b/.playwright/screenshots/ellipsize-checkbox-list-with-empty-clip.png differ diff --git a/.playwright/screenshots/ellipsize-checkbox-list-with-empty-head.png b/.playwright/screenshots/ellipsize-checkbox-list-with-empty-head.png new file mode 100644 index 00000000..11df59ab Binary files /dev/null and b/.playwright/screenshots/ellipsize-checkbox-list-with-empty-head.png differ diff --git a/.playwright/screenshots/ellipsize-checkbox-list-with-empty-tail.png b/.playwright/screenshots/ellipsize-checkbox-list-with-empty-tail.png new file mode 100644 index 00000000..b12edb46 Binary files /dev/null and b/.playwright/screenshots/ellipsize-checkbox-list-with-empty-tail.png differ diff --git a/.playwright/screenshots/ellipsize-different-paragraph-style-clip.png b/.playwright/screenshots/ellipsize-different-paragraph-style-clip.png new file mode 100644 index 00000000..aaa78b98 Binary files /dev/null and b/.playwright/screenshots/ellipsize-different-paragraph-style-clip.png differ diff --git a/.playwright/screenshots/ellipsize-different-paragraph-style-head.png b/.playwright/screenshots/ellipsize-different-paragraph-style-head.png new file mode 100644 index 00000000..6fb652a7 Binary files /dev/null and b/.playwright/screenshots/ellipsize-different-paragraph-style-head.png differ diff --git a/.playwright/screenshots/ellipsize-different-paragraph-style-tail.png b/.playwright/screenshots/ellipsize-different-paragraph-style-tail.png new file mode 100644 index 00000000..48ed7b50 Binary files /dev/null and b/.playwright/screenshots/ellipsize-different-paragraph-style-tail.png differ diff --git a/.playwright/screenshots/ellipsize-different-paragraph-style-with-empty-line-clip.png b/.playwright/screenshots/ellipsize-different-paragraph-style-with-empty-line-clip.png new file mode 100644 index 00000000..268d926e Binary files /dev/null and b/.playwright/screenshots/ellipsize-different-paragraph-style-with-empty-line-clip.png differ diff --git a/.playwright/screenshots/ellipsize-different-paragraph-style-with-empty-line-head.png b/.playwright/screenshots/ellipsize-different-paragraph-style-with-empty-line-head.png new file mode 100644 index 00000000..ef0807bb Binary files /dev/null and b/.playwright/screenshots/ellipsize-different-paragraph-style-with-empty-line-head.png differ diff --git a/.playwright/screenshots/ellipsize-different-paragraph-style-with-empty-line-tail.png b/.playwright/screenshots/ellipsize-different-paragraph-style-with-empty-line-tail.png new file mode 100644 index 00000000..0cb966e8 Binary files /dev/null and b/.playwright/screenshots/ellipsize-different-paragraph-style-with-empty-line-tail.png differ diff --git a/.playwright/screenshots/ellipsize-empty-in-the-middle-clip.png b/.playwright/screenshots/ellipsize-empty-in-the-middle-clip.png new file mode 100644 index 00000000..04b9902c Binary files /dev/null and b/.playwright/screenshots/ellipsize-empty-in-the-middle-clip.png differ diff --git a/.playwright/screenshots/ellipsize-empty-in-the-middle-head.png b/.playwright/screenshots/ellipsize-empty-in-the-middle-head.png new file mode 100644 index 00000000..08877bee Binary files /dev/null and b/.playwright/screenshots/ellipsize-empty-in-the-middle-head.png differ diff --git a/.playwright/screenshots/ellipsize-empty-in-the-middle-tail.png b/.playwright/screenshots/ellipsize-empty-in-the-middle-tail.png new file mode 100644 index 00000000..a6f61749 Binary files /dev/null and b/.playwright/screenshots/ellipsize-empty-in-the-middle-tail.png differ diff --git a/.playwright/screenshots/ellipsize-inline-images-clip.png b/.playwright/screenshots/ellipsize-inline-images-clip.png new file mode 100644 index 00000000..8b148c0a Binary files /dev/null and b/.playwright/screenshots/ellipsize-inline-images-clip.png differ diff --git a/.playwright/screenshots/ellipsize-inline-images-head.png b/.playwright/screenshots/ellipsize-inline-images-head.png new file mode 100644 index 00000000..8b0d9f7f Binary files /dev/null and b/.playwright/screenshots/ellipsize-inline-images-head.png differ diff --git a/.playwright/screenshots/ellipsize-inline-images-tail.png b/.playwright/screenshots/ellipsize-inline-images-tail.png new file mode 100644 index 00000000..2bf67c32 Binary files /dev/null and b/.playwright/screenshots/ellipsize-inline-images-tail.png differ diff --git a/.playwright/screenshots/ellipsize-middle-breaklines-head-fallback.png b/.playwright/screenshots/ellipsize-middle-breaklines-head-fallback.png new file mode 100644 index 00000000..5838336f Binary files /dev/null and b/.playwright/screenshots/ellipsize-middle-breaklines-head-fallback.png differ diff --git a/.playwright/screenshots/ellipsize-middle-different-blocks-head-fallback.png b/.playwright/screenshots/ellipsize-middle-different-blocks-head-fallback.png new file mode 100644 index 00000000..8772dc98 Binary files /dev/null and b/.playwright/screenshots/ellipsize-middle-different-blocks-head-fallback.png differ diff --git a/.playwright/screenshots/ellipsize-middle-different-paragraph-style-multiple-lines.png b/.playwright/screenshots/ellipsize-middle-different-paragraph-style-multiple-lines.png new file mode 100644 index 00000000..72faabaa Binary files /dev/null and b/.playwright/screenshots/ellipsize-middle-different-paragraph-style-multiple-lines.png differ diff --git a/.playwright/screenshots/ellipsize-middle-different-paragraph-style.png b/.playwright/screenshots/ellipsize-middle-different-paragraph-style.png new file mode 100644 index 00000000..e4a554d5 Binary files /dev/null and b/.playwright/screenshots/ellipsize-middle-different-paragraph-style.png differ diff --git a/.playwright/screenshots/ellipsize-middle-empty-lines.png b/.playwright/screenshots/ellipsize-middle-empty-lines.png new file mode 100644 index 00000000..6ccd1133 Binary files /dev/null and b/.playwright/screenshots/ellipsize-middle-empty-lines.png differ diff --git a/.playwright/screenshots/ellipsize-middle-one-paragraph-many-inline-images.png b/.playwright/screenshots/ellipsize-middle-one-paragraph-many-inline-images.png new file mode 100644 index 00000000..d4e8013a Binary files /dev/null and b/.playwright/screenshots/ellipsize-middle-one-paragraph-many-inline-images.png differ diff --git a/.playwright/screenshots/ellipsize-middle-one-paragraph-many-lines-overflowing.png b/.playwright/screenshots/ellipsize-middle-one-paragraph-many-lines-overflowing.png new file mode 100644 index 00000000..33ec491b Binary files /dev/null and b/.playwright/screenshots/ellipsize-middle-one-paragraph-many-lines-overflowing.png differ diff --git a/.playwright/screenshots/ellipsize-middle-one-paragraph-one-line-overflowing.png b/.playwright/screenshots/ellipsize-middle-one-paragraph-one-line-overflowing.png new file mode 100644 index 00000000..a3881fd6 Binary files /dev/null and b/.playwright/screenshots/ellipsize-middle-one-paragraph-one-line-overflowing.png differ diff --git a/.playwright/screenshots/ellipsize-middle-other-paragraphs-and-break-lines-inside-block-style.png b/.playwright/screenshots/ellipsize-middle-other-paragraphs-and-break-lines-inside-block-style.png new file mode 100644 index 00000000..9be2e1e7 Binary files /dev/null and b/.playwright/screenshots/ellipsize-middle-other-paragraphs-and-break-lines-inside-block-style.png differ diff --git a/.playwright/screenshots/ellipsize-multiple-short-paragraphs-clip.png b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-clip.png new file mode 100644 index 00000000..ca3b78f5 Binary files /dev/null and b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-clip.png differ diff --git a/.playwright/screenshots/ellipsize-multiple-short-paragraphs-head.png b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-head.png new file mode 100644 index 00000000..52c565a2 Binary files /dev/null and b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-head.png differ diff --git a/.playwright/screenshots/ellipsize-multiple-short-paragraphs-tail.png b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-tail.png new file mode 100644 index 00000000..627bc784 Binary files /dev/null and b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-tail.png differ diff --git a/.playwright/screenshots/ellipsize-multiple-short-paragraphs-with-last-overflow-clip.png b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-with-last-overflow-clip.png new file mode 100644 index 00000000..ca3b78f5 Binary files /dev/null and b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-with-last-overflow-clip.png differ diff --git a/.playwright/screenshots/ellipsize-multiple-short-paragraphs-with-last-overflow-head.png b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-with-last-overflow-head.png new file mode 100644 index 00000000..d10d5604 Binary files /dev/null and b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-with-last-overflow-head.png differ diff --git a/.playwright/screenshots/ellipsize-multiple-short-paragraphs-with-last-overflow-tail.png b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-with-last-overflow-tail.png new file mode 100644 index 00000000..627bc784 Binary files /dev/null and b/.playwright/screenshots/ellipsize-multiple-short-paragraphs-with-last-overflow-tail.png differ diff --git a/.playwright/screenshots/ellipsize-one-word-wrapping-clip.png b/.playwright/screenshots/ellipsize-one-word-wrapping-clip.png new file mode 100644 index 00000000..32d8960f Binary files /dev/null and b/.playwright/screenshots/ellipsize-one-word-wrapping-clip.png differ diff --git a/.playwright/screenshots/ellipsize-one-word-wrapping-head.png b/.playwright/screenshots/ellipsize-one-word-wrapping-head.png new file mode 100644 index 00000000..a1b215dd Binary files /dev/null and b/.playwright/screenshots/ellipsize-one-word-wrapping-head.png differ diff --git a/.playwright/screenshots/ellipsize-one-word-wrapping-tail.png b/.playwright/screenshots/ellipsize-one-word-wrapping-tail.png new file mode 100644 index 00000000..ee119f89 Binary files /dev/null and b/.playwright/screenshots/ellipsize-one-word-wrapping-tail.png differ diff --git a/.playwright/screenshots/ellipsize-ordered-list-clip.png b/.playwright/screenshots/ellipsize-ordered-list-clip.png new file mode 100644 index 00000000..1109dcc4 Binary files /dev/null and b/.playwright/screenshots/ellipsize-ordered-list-clip.png differ diff --git a/.playwright/screenshots/ellipsize-ordered-list-head.png b/.playwright/screenshots/ellipsize-ordered-list-head.png new file mode 100644 index 00000000..966b3316 Binary files /dev/null and b/.playwright/screenshots/ellipsize-ordered-list-head.png differ diff --git a/.playwright/screenshots/ellipsize-ordered-list-only-empty-clip.png b/.playwright/screenshots/ellipsize-ordered-list-only-empty-clip.png new file mode 100644 index 00000000..0f7105d9 Binary files /dev/null and b/.playwright/screenshots/ellipsize-ordered-list-only-empty-clip.png differ diff --git a/.playwright/screenshots/ellipsize-ordered-list-only-empty-head.png b/.playwright/screenshots/ellipsize-ordered-list-only-empty-head.png new file mode 100644 index 00000000..44b368d9 Binary files /dev/null and b/.playwright/screenshots/ellipsize-ordered-list-only-empty-head.png differ diff --git a/.playwright/screenshots/ellipsize-ordered-list-only-empty-tail.png b/.playwright/screenshots/ellipsize-ordered-list-only-empty-tail.png new file mode 100644 index 00000000..44b368d9 Binary files /dev/null and b/.playwright/screenshots/ellipsize-ordered-list-only-empty-tail.png differ diff --git a/.playwright/screenshots/ellipsize-ordered-list-tail.png b/.playwright/screenshots/ellipsize-ordered-list-tail.png new file mode 100644 index 00000000..8d8632ef Binary files /dev/null and b/.playwright/screenshots/ellipsize-ordered-list-tail.png differ diff --git a/.playwright/screenshots/ellipsize-ordered-list-with-empty-clip.png b/.playwright/screenshots/ellipsize-ordered-list-with-empty-clip.png new file mode 100644 index 00000000..d2ceef00 Binary files /dev/null and b/.playwright/screenshots/ellipsize-ordered-list-with-empty-clip.png differ diff --git a/.playwright/screenshots/ellipsize-ordered-list-with-empty-head.png b/.playwright/screenshots/ellipsize-ordered-list-with-empty-head.png new file mode 100644 index 00000000..48168aac Binary files /dev/null and b/.playwright/screenshots/ellipsize-ordered-list-with-empty-head.png differ diff --git a/.playwright/screenshots/ellipsize-ordered-list-with-empty-tail.png b/.playwright/screenshots/ellipsize-ordered-list-with-empty-tail.png new file mode 100644 index 00000000..4a9b282c Binary files /dev/null and b/.playwright/screenshots/ellipsize-ordered-list-with-empty-tail.png differ diff --git a/.playwright/screenshots/ellipsize-paragraph-fit-clip.png b/.playwright/screenshots/ellipsize-paragraph-fit-clip.png new file mode 100644 index 00000000..87805c90 Binary files /dev/null and b/.playwright/screenshots/ellipsize-paragraph-fit-clip.png differ diff --git a/.playwright/screenshots/ellipsize-paragraph-fit-head.png b/.playwright/screenshots/ellipsize-paragraph-fit-head.png new file mode 100644 index 00000000..87805c90 Binary files /dev/null and b/.playwright/screenshots/ellipsize-paragraph-fit-head.png differ diff --git a/.playwright/screenshots/ellipsize-paragraph-fit-tail.png b/.playwright/screenshots/ellipsize-paragraph-fit-tail.png new file mode 100644 index 00000000..87805c90 Binary files /dev/null and b/.playwright/screenshots/ellipsize-paragraph-fit-tail.png differ diff --git a/.playwright/screenshots/ellipsize-paragraph-styles-mix-clip.png b/.playwright/screenshots/ellipsize-paragraph-styles-mix-clip.png new file mode 100644 index 00000000..770d71cb Binary files /dev/null and b/.playwright/screenshots/ellipsize-paragraph-styles-mix-clip.png differ diff --git a/.playwright/screenshots/ellipsize-paragraph-styles-mix-head.png b/.playwright/screenshots/ellipsize-paragraph-styles-mix-head.png new file mode 100644 index 00000000..efd68547 Binary files /dev/null and b/.playwright/screenshots/ellipsize-paragraph-styles-mix-head.png differ diff --git a/.playwright/screenshots/ellipsize-paragraph-styles-mix-tail.png b/.playwright/screenshots/ellipsize-paragraph-styles-mix-tail.png new file mode 100644 index 00000000..3ddffbd1 Binary files /dev/null and b/.playwright/screenshots/ellipsize-paragraph-styles-mix-tail.png differ diff --git a/.playwright/screenshots/ellipsize-single-word-clip.png b/.playwright/screenshots/ellipsize-single-word-clip.png new file mode 100644 index 00000000..d80cfbe0 Binary files /dev/null and b/.playwright/screenshots/ellipsize-single-word-clip.png differ diff --git a/.playwright/screenshots/ellipsize-single-word-head.png b/.playwright/screenshots/ellipsize-single-word-head.png new file mode 100644 index 00000000..2af83ea8 Binary files /dev/null and b/.playwright/screenshots/ellipsize-single-word-head.png differ diff --git a/.playwright/screenshots/ellipsize-single-word-tail.png b/.playwright/screenshots/ellipsize-single-word-tail.png new file mode 100644 index 00000000..8e18ba7e Binary files /dev/null and b/.playwright/screenshots/ellipsize-single-word-tail.png differ diff --git a/.playwright/screenshots/ellipsize-unordered-list-clip.png b/.playwright/screenshots/ellipsize-unordered-list-clip.png new file mode 100644 index 00000000..08dc90d4 Binary files /dev/null and b/.playwright/screenshots/ellipsize-unordered-list-clip.png differ diff --git a/.playwright/screenshots/ellipsize-unordered-list-head.png b/.playwright/screenshots/ellipsize-unordered-list-head.png new file mode 100644 index 00000000..632fbaab Binary files /dev/null and b/.playwright/screenshots/ellipsize-unordered-list-head.png differ diff --git a/.playwright/screenshots/ellipsize-unordered-list-only-empty-clip.png b/.playwright/screenshots/ellipsize-unordered-list-only-empty-clip.png new file mode 100644 index 00000000..623aa9e7 Binary files /dev/null and b/.playwright/screenshots/ellipsize-unordered-list-only-empty-clip.png differ diff --git a/.playwright/screenshots/ellipsize-unordered-list-only-empty-head.png b/.playwright/screenshots/ellipsize-unordered-list-only-empty-head.png new file mode 100644 index 00000000..d1976eec Binary files /dev/null and b/.playwright/screenshots/ellipsize-unordered-list-only-empty-head.png differ diff --git a/.playwright/screenshots/ellipsize-unordered-list-only-empty-tail.png b/.playwright/screenshots/ellipsize-unordered-list-only-empty-tail.png new file mode 100644 index 00000000..d1976eec Binary files /dev/null and b/.playwright/screenshots/ellipsize-unordered-list-only-empty-tail.png differ diff --git a/.playwright/screenshots/ellipsize-unordered-list-tail.png b/.playwright/screenshots/ellipsize-unordered-list-tail.png new file mode 100644 index 00000000..bac86377 Binary files /dev/null and b/.playwright/screenshots/ellipsize-unordered-list-tail.png differ diff --git a/.playwright/screenshots/ellipsize-unordered-list-with-empty-clip.png b/.playwright/screenshots/ellipsize-unordered-list-with-empty-clip.png new file mode 100644 index 00000000..98a7731f Binary files /dev/null and b/.playwright/screenshots/ellipsize-unordered-list-with-empty-clip.png differ diff --git a/.playwright/screenshots/ellipsize-unordered-list-with-empty-head.png b/.playwright/screenshots/ellipsize-unordered-list-with-empty-head.png new file mode 100644 index 00000000..f0ac8681 Binary files /dev/null and b/.playwright/screenshots/ellipsize-unordered-list-with-empty-head.png differ diff --git a/.playwright/screenshots/ellipsize-unordered-list-with-empty-tail.png b/.playwright/screenshots/ellipsize-unordered-list-with-empty-tail.png new file mode 100644 index 00000000..1b9e3d40 Binary files /dev/null and b/.playwright/screenshots/ellipsize-unordered-list-with-empty-tail.png differ diff --git a/.playwright/screenshots/ellipsize-very-long-paragraph-clip.png b/.playwright/screenshots/ellipsize-very-long-paragraph-clip.png new file mode 100644 index 00000000..963c3908 Binary files /dev/null and b/.playwright/screenshots/ellipsize-very-long-paragraph-clip.png differ diff --git a/.playwright/screenshots/ellipsize-very-long-paragraph-head.png b/.playwright/screenshots/ellipsize-very-long-paragraph-head.png new file mode 100644 index 00000000..5b7d2663 Binary files /dev/null and b/.playwright/screenshots/ellipsize-very-long-paragraph-head.png differ diff --git a/.playwright/screenshots/ellipsize-very-long-paragraph-tail.png b/.playwright/screenshots/ellipsize-very-long-paragraph-tail.png new file mode 100644 index 00000000..42dd878c Binary files /dev/null and b/.playwright/screenshots/ellipsize-very-long-paragraph-tail.png differ diff --git a/.playwright/tests/ellipsizeVisual.spec.ts b/.playwright/tests/ellipsizeVisual.spec.ts new file mode 100644 index 00000000..0ba75802 --- /dev/null +++ b/.playwright/tests/ellipsizeVisual.spec.ts @@ -0,0 +1,313 @@ +import { test, expect, type Locator, type Page } from '@playwright/test'; + +test.setTimeout(90_000); + +type EllipsizeMode = 'head' | 'middle' | 'tail' | 'clip'; + +const LOREM_IPSUM = `

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur porta placerat nulla vitae tincidunt. In tellus neque, volutpat id molestie ut, dapibus sit amet justo. Sed nec lobortis orci. Vestibulum magna est, placerat vitae libero ut, viverra mollis purus. Curabitur lacinia a libero non congue. Vestibulum et velit lacinia, feugiat odio eget, faucibus sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus eu erat commodo, condimentum augue eu, fringilla purus. Morbi at nisi eget felis dignissim fringilla. Pellentesque blandit porttitor libero. Donec accumsan, leo eget ultricies rutrum, lorem purus aliquet quam, sit amet pellentesque lectus nulla non nulla.

`; + +const sel = { + root: '[data-testid="test-ellipsize-root"]', + display: '[data-testid="test-ellipsize-display"]', + displayInner: '[data-testid="test-ellipsize-display"] .et-view', + htmlInput: '[data-testid="test-ellipsize-html-input"]', + setValueButton: '[data-testid="test-ellipsize-set-value-button"]', + numberOfLinesInput: '[data-testid="test-ellipsize-number-of-lines-input"]', + numberOfLinesOutput: '[data-testid="test-ellipsize-number-of-lines-output"]', + modeButton: (mode: EllipsizeMode) => + `[data-testid="test-ellipsize-mode-${mode}"]`, + modeOutput: '[data-testid="test-ellipsize-mode-output"]', + valueOutput: '[data-testid="test-ellipsize-value-output"]', +} as const; + +function displayLocator(page: Page): Locator { + return page.locator(sel.display); +} + +async function gotoTestEllipsize(page: Page): Promise { + await page.goto('/test-ellipsize'); + await page.waitForSelector(sel.displayInner); +} + +async function setValue(page: Page, html: string): Promise { + await page.fill(sel.htmlInput, html); + await page.click(sel.setValueButton); + await expect + .poll(async () => (await page.locator(sel.valueOutput).textContent()) ?? '') + .toBe(html); +} + +async function setNumberOfLines(page: Page, lines: number): Promise { + await page.fill(sel.numberOfLinesInput, String(lines)); + await expect + .poll( + async () => + (await page.locator(sel.numberOfLinesOutput).textContent())?.trim() ?? + '' + ) + .toBe(String(lines)); +} + +async function setMode(page: Page, mode: EllipsizeMode): Promise { + await page.click(sel.modeButton(mode)); + await expect + .poll( + async () => + (await page.locator(sel.modeOutput).textContent())?.trim() ?? '' + ) + .toBe(mode); +} + +const SHARED_MODES: EllipsizeMode[] = ['tail', 'head', 'clip']; + +type EllipsizeCase = { + name: string; + slug: string; + html: string; + numberOfLines: number; +}; + +const SHARED_CASES: EllipsizeCase[] = [ + { + name: 'paragraph that fits', + slug: 'paragraph-fit', + html: `

hello that is a paragraph that should fit and require no ellipsis

`, + numberOfLines: 2, + }, + { + name: 'single word wrapping to multiple lines', + slug: 'single-word', + html: + `

Verylongpieceoftextfitintoonelinesowecancheckthiscasewherethereis` + + `averylongpieceoftextanditwrapsaroundsomenumberoflinesandthatwillbetruncated` + + `accordinglytothesetellipsizemodeintheenrichedtextcomponent

`, + numberOfLines: 2, + }, + { + name: 'a long word that causes line wrapping', + slug: 'one-word-wrapping', + html: + `

Some paragraph with a long word that will not fit and wrap.` + + ` The long word: Konstantynopolitanczykowianeczka

`, + numberOfLines: 2, + }, + { + name: 'paragraph with a number of lines much greater than the given limit', + slug: 'very-long-paragraph', + html: LOREM_IPSUM, + numberOfLines: 2, + }, + { + name: 'a number of paragraphs much greater than the given limit', + slug: 'multiple-short-paragraphs', + html: `

first

second

third

fourth

fifth

sixth

seventh

`, + numberOfLines: 4, + }, + { + name: 'a number of paragraphs much greater than the given limit and the last one overflows', + slug: 'multiple-short-paragraphs-with-last-overflow', + html: `

first

second

third

fourth

fifth

sixth

seventh line that will be long enough that it overflows to the next 8th line

`, + numberOfLines: 4, + }, + { + name: 'some text between empty paragraphs', + slug: 'between-empty-paragraphs', + html: `

between empty paragraphs


`, + numberOfLines: 2, + }, + { + name: 'some text between multiple empty lines', + slug: 'between-multiple-empty-lines', + html: `

between empty paragraphs


`, + numberOfLines: 2, + }, + { + name: 'some empty paragraphs in the middle', + slug: 'empty-in-the-middle', + html: `

first line




last line

`, + numberOfLines: 2, + }, + { + name: 'unordered list', + slug: 'unordered-list', + html: `
  • first
  • second
  • third
`, + numberOfLines: 2, + }, + { + name: 'unordered list with empty elements', + slug: 'unordered-list-with-empty', + html: `
  • second
  • fourth
`, + numberOfLines: 3, + }, + { + name: 'unordered list with only empty elements', + slug: 'unordered-list-only-empty', + html: `
`, + numberOfLines: 2, + }, + { + name: 'ordered list', + slug: 'ordered-list', + html: `
  1. first
  2. second
  3. third
`, + numberOfLines: 2, + }, + { + name: 'ordered list with empty elements', + slug: 'ordered-list-with-empty', + html: `
  1. second
  2. fourth
`, + numberOfLines: 3, + }, + { + name: 'ordered list with only empty elements', + slug: 'ordered-list-only-empty', + html: `
`, + numberOfLines: 2, + }, + { + name: 'checkbox list', + slug: 'checkbox-list', + html: `
  • first
  • second
  • third
`, + numberOfLines: 2, + }, + { + name: 'checkbox list with empty elements', + slug: 'checkbox-list-with-empty', + html: `
  • second
  • fourth
`, + numberOfLines: 3, + }, + { + name: 'checkbox list with only empty elements', + slug: 'checkbox-list-only-empty', + html: `
`, + numberOfLines: 2, + }, + { + name: 'different paragraph style', + slug: 'different-paragraph-style', + html: `

this is a pretty long blockquote - a different block style paragraph, long enough to overflow in the given number of lines.

`, + numberOfLines: 2, + }, + { + name: 'different paragraph style with an empty line', + slug: 'different-paragraph-style-with-empty-line', + html: `

this is a pretty short blockquote.


This is a line after an empty line.

`, + numberOfLines: 2, + }, + { + name: 'mixing different paragraph styles', + slug: 'paragraph-styles-mix', + html: `

This is a normal paragraph.

This is a codeblock that will be long enough to overflow.

`, + numberOfLines: 2, + }, + { + name: 'inline images', + slug: 'inline-images', + html: + `

This is a line with an inline image.` + + `

This is a second line and the inline image ` + + `will make it overflow to the next line.

This is the last line with an inline image.

`, + numberOfLines: 2, + }, +]; + +for (const mode of SHARED_MODES) { + test.describe(`EnrichedText ellipsize - ${mode}`, () => { + for (const c of SHARED_CASES) { + test(c.name, async ({ page }) => { + await gotoTestEllipsize(page); + await setValue(page, c.html); + await setNumberOfLines(page, c.numberOfLines); + await setMode(page, mode); + + await expect(displayLocator(page)).toHaveScreenshot( + `ellipsize-${c.slug}-${mode}.png` + ); + }); + } + }); +} + +test.describe('EnrichedText ellipsize - middle', () => { + const middleEllipsizeCases: EllipsizeCase[] = [ + { + name: 'all text within one paragraph, with one line exceeding the limit', + slug: 'one-paragraph-one-line-overflowing', + html: + `

This is a fairly long paragraph that should wrap` + + ` across three lines so the truncation has something to chew on.

`, + numberOfLines: 2, + }, + { + name: 'all text within one paragraph, but with at least two lines exceeding the limit', + slug: 'one-paragraph-many-lines-overflowing', + html: + `

This is a fairly long paragraph that should wrap across four lines so the` + + ` truncation has something to chew on. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

`, + numberOfLines: 2, + }, + { + name: 'all text within one paragraph but with multiple inline images', + slug: 'one-paragraph-many-inline-images', + html: + `

Some paragraph text overflowing but with some inline images inside the eaten text and before, after dummytext the rendered ellipsis

`, + numberOfLines: 2, + }, + { + name: 'different paragraphs will be truncated with the middle ellipsis if the needed last lines belong to a single paragraph', + slug: 'different-paragraph-style', + html: `

first paragraph.

Different paragraph style that will overflow to the next line
`, + numberOfLines: 2, + }, + { + name: 'different paragraph style with many lines', + slug: 'different-paragraph-style-multiple-lines', + html: + `

first paragraph.

Different paragraph style and the text ` + + `that will overflow to the next lines of that block verylongwordthatwillnotfitinthelineandwilloverflow

`, + numberOfLines: 2, + }, + { + name: 'ellipsis on the last paragraph with leading other paragraphs and break lines', + slug: 'other-paragraphs-and-break-lines-inside-block-style', + html: + `

Normal style.

First line before empty ones.



Last ` + + `paragraph inside a block style that will overflow to three different lines, so we can check this case.

`, + numberOfLines: 5, + }, + { + name: 'empty lines are preserved', + slug: 'empty-lines', + html: `

first line


last line that will overflow and will have an ellipsis

`, + numberOfLines: 4, + }, + // tests checking a proper fallback to the head ellipsis + { + name: 'when the overflowing lines are different blocks, it fallbacks to head ellipsis', + slug: 'different-blocks-head-fallback', + html: `

first line

second line

third line

`, + numberOfLines: 2, + }, + { + name: 'breaklines inside a block style are considered as different paragraphs', + slug: 'breaklines-head-fallback', + html: `

first line



`, + numberOfLines: 2, + }, + ]; + + for (const c of middleEllipsizeCases) { + test(c.name, async ({ page }) => { + await gotoTestEllipsize(page); + await setValue(page, c.html); + await setNumberOfLines(page, c.numberOfLines); + await setMode(page, 'middle'); + + await expect(displayLocator(page)).toHaveScreenshot( + `ellipsize-middle-${c.slug}.png` + ); + }); + } +}); diff --git a/apps/example-web/src/App.tsx b/apps/example-web/src/App.tsx index 8fa6e035..05e6ed04 100644 --- a/apps/example-web/src/App.tsx +++ b/apps/example-web/src/App.tsx @@ -236,7 +236,8 @@ function App() { ?.getHTML() .then((html) => { setEnrichedTextValue(html); - ref.current?.setValue(''); + // temporary for making the testing easier + // ref.current?.setValue(''); }) .catch((error: unknown) => { setEnrichedTextValue(''); @@ -334,6 +335,15 @@ function App() {

Enriched Text

+ + {enrichedTextValue} + + {/*temporary second component to make testing easier*/} ; } + if (path === '/test-ellipsize') { + return ; + } + return ; } diff --git a/apps/example-web/src/testScreens/TestEllipsize.tsx b/apps/example-web/src/testScreens/TestEllipsize.tsx new file mode 100644 index 00000000..489b811c --- /dev/null +++ b/apps/example-web/src/testScreens/TestEllipsize.tsx @@ -0,0 +1,103 @@ +import { useState, type ChangeEvent } from 'react'; +import { + EnrichedText, + type EnrichedTextProps, +} from 'react-native-enriched-html'; +import type { TextStyle } from 'react-native'; +import { WEB_DEFAULT_HTML_STYLE } from '../defaultHtmlStyle'; + +type EllipsizeMode = NonNullable; + +const ELLIPSIZE_MODES: EllipsizeMode[] = ['head', 'middle', 'tail', 'clip']; + +export function TestEllipsize() { + const [htmlInput, setHtmlInput] = useState(''); + const [value, setValue] = useState(''); + const [numberOfLines, setNumberOfLines] = useState(2); + const [ellipsizeMode, setEllipsizeMode] = useState('tail'); + + return ( +
+
+ + {value} + +
+ +
+ + ) => { + setNumberOfLines(Number(e.target.value)); + }} + /> +
+ +
+ {ELLIPSIZE_MODES.map((mode) => ( + + ))} +
+ +