diff --git a/.playwright/screenshots/alignment-mixed.png b/.playwright/screenshots/alignment-mixed.png index e4bd7250..c4177a5a 100644 Binary files a/.playwright/screenshots/alignment-mixed.png and b/.playwright/screenshots/alignment-mixed.png differ diff --git a/.playwright/screenshots/display-alignment-blockquotes.png b/.playwright/screenshots/display-alignment-blockquotes.png new file mode 100644 index 00000000..22082495 Binary files /dev/null and b/.playwright/screenshots/display-alignment-blockquotes.png differ diff --git a/.playwright/screenshots/display-alignment-checkbox.png b/.playwright/screenshots/display-alignment-checkbox.png new file mode 100644 index 00000000..16a347cf Binary files /dev/null and b/.playwright/screenshots/display-alignment-checkbox.png differ diff --git a/.playwright/screenshots/display-alignment-headings.png b/.playwright/screenshots/display-alignment-headings.png new file mode 100644 index 00000000..a9879b4b Binary files /dev/null and b/.playwright/screenshots/display-alignment-headings.png differ diff --git a/.playwright/screenshots/display-alignment-mixed-lists.png b/.playwright/screenshots/display-alignment-mixed-lists.png new file mode 100644 index 00000000..3d28fd05 Binary files /dev/null and b/.playwright/screenshots/display-alignment-mixed-lists.png differ diff --git a/.playwright/screenshots/display-alignment-ol.png b/.playwright/screenshots/display-alignment-ol.png new file mode 100644 index 00000000..dab2f7ee Binary files /dev/null and b/.playwright/screenshots/display-alignment-ol.png differ diff --git a/.playwright/screenshots/display-alignment-paragraphs.png b/.playwright/screenshots/display-alignment-paragraphs.png new file mode 100644 index 00000000..654fda31 Binary files /dev/null and b/.playwright/screenshots/display-alignment-paragraphs.png differ diff --git a/.playwright/screenshots/display-alignment-ul.png b/.playwright/screenshots/display-alignment-ul.png new file mode 100644 index 00000000..1f46b826 Binary files /dev/null and b/.playwright/screenshots/display-alignment-ul.png differ diff --git a/.playwright/screenshots/enriched-text-all-list-types.png b/.playwright/screenshots/enriched-text-all-list-types.png index 2bcf5628..a7628b23 100644 Binary files a/.playwright/screenshots/enriched-text-all-list-types.png and b/.playwright/screenshots/enriched-text-all-list-types.png differ diff --git a/.playwright/screenshots/enriched-text-checkbox-list-checked.png b/.playwright/screenshots/enriched-text-checkbox-list-checked.png index 5d7449ea..69d80595 100644 Binary files a/.playwright/screenshots/enriched-text-checkbox-list-checked.png and b/.playwright/screenshots/enriched-text-checkbox-list-checked.png differ diff --git a/.playwright/screenshots/enriched-text-checkbox-list-empty-items.png b/.playwright/screenshots/enriched-text-checkbox-list-empty-items.png index b4cf4fe0..fc5b5658 100644 Binary files a/.playwright/screenshots/enriched-text-checkbox-list-empty-items.png and b/.playwright/screenshots/enriched-text-checkbox-list-empty-items.png differ diff --git a/.playwright/screenshots/enriched-text-checkbox-list-unchecked.png b/.playwright/screenshots/enriched-text-checkbox-list-unchecked.png index 14d0b356..fce7f975 100644 Binary files a/.playwright/screenshots/enriched-text-checkbox-list-unchecked.png and b/.playwright/screenshots/enriched-text-checkbox-list-unchecked.png differ diff --git a/.playwright/screenshots/enriched-text-checkbox-list-wrapped.png b/.playwright/screenshots/enriched-text-checkbox-list-wrapped.png index 2c6168a0..27d2ef38 100644 Binary files a/.playwright/screenshots/enriched-text-checkbox-list-wrapped.png and b/.playwright/screenshots/enriched-text-checkbox-list-wrapped.png differ diff --git a/.playwright/screenshots/images-checkbox-list-placeholder.png b/.playwright/screenshots/images-checkbox-list-placeholder.png index b0226c0e..d0f5fe7d 100644 Binary files a/.playwright/screenshots/images-checkbox-list-placeholder.png and b/.playwright/screenshots/images-checkbox-list-placeholder.png differ diff --git a/.playwright/screenshots/list-keyboard-backspace-after-lift-checkbox.png b/.playwright/screenshots/list-keyboard-backspace-after-lift-checkbox.png index 4e2546ba..b012fd9b 100644 Binary files a/.playwright/screenshots/list-keyboard-backspace-after-lift-checkbox.png and b/.playwright/screenshots/list-keyboard-backspace-after-lift-checkbox.png differ diff --git a/.playwright/screenshots/list-keyboard-backspace-after-merge-checkbox.png b/.playwright/screenshots/list-keyboard-backspace-after-merge-checkbox.png index 5ac8507c..0d67e85b 100644 Binary files a/.playwright/screenshots/list-keyboard-backspace-after-merge-checkbox.png and b/.playwright/screenshots/list-keyboard-backspace-after-merge-checkbox.png differ diff --git a/.playwright/screenshots/list-keyboard-enter-causes-scrolling-checkbox.png b/.playwright/screenshots/list-keyboard-enter-causes-scrolling-checkbox.png index 047ff686..923a321c 100644 Binary files a/.playwright/screenshots/list-keyboard-enter-causes-scrolling-checkbox.png and b/.playwright/screenshots/list-keyboard-enter-causes-scrolling-checkbox.png differ diff --git a/.playwright/screenshots/list-keyboard-enter-checkbox.png b/.playwright/screenshots/list-keyboard-enter-checkbox.png index 645655f6..c2f0c16e 100644 Binary files a/.playwright/screenshots/list-keyboard-enter-checkbox.png and b/.playwright/screenshots/list-keyboard-enter-checkbox.png differ diff --git a/.playwright/screenshots/paragraph-styles-visual-checkbox-list-wrapped.png b/.playwright/screenshots/paragraph-styles-visual-checkbox-list-wrapped.png index ea5ff167..d23bb7ab 100644 Binary files a/.playwright/screenshots/paragraph-styles-visual-checkbox-list-wrapped.png and b/.playwright/screenshots/paragraph-styles-visual-checkbox-list-wrapped.png differ diff --git a/.playwright/screenshots/paragraph-styles-visual-checkbox-list.png b/.playwright/screenshots/paragraph-styles-visual-checkbox-list.png index c491b81b..856ad159 100644 Binary files a/.playwright/screenshots/paragraph-styles-visual-checkbox-list.png and b/.playwright/screenshots/paragraph-styles-visual-checkbox-list.png differ diff --git a/.playwright/tests/enrichedTextTextAlignmentVisual.spec.ts b/.playwright/tests/enrichedTextTextAlignmentVisual.spec.ts new file mode 100644 index 00000000..11b5af95 --- /dev/null +++ b/.playwright/tests/enrichedTextTextAlignmentVisual.spec.ts @@ -0,0 +1,139 @@ +import { test, expect, type Locator, type Page } from '@playwright/test'; + +test.setTimeout(90_000); + +const sel = { + root: '[data-testid="test-enriched-text-root"]', + htmlInput: '[data-testid="test-enriched-text-html-input"]', + setValueButton: '[data-testid="test-enriched-text-set-value-button"]', + toggleWidthButton: '[data-testid="test-enriched-text-toggle-width-button"]', + valueOutput: '[data-testid="test-enriched-text-value-output"]', + display: '[data-testid="test-enriched-text-display"]', + displayInner: '[data-testid="test-enriched-text-display"] .et-view', +} as const; + +function displayLocator(page: Page): Locator { + return page.locator(sel.display); +} + +async function gotoTestEnrichedText(page: Page): Promise { + await page.goto('/test-enriched-text'); + await page.waitForSelector(sel.displayInner); + await page.click(sel.toggleWidthButton); +} + +async function setEnrichedTextValue(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); +} + +test.describe('visual: alignments for typography and blocks', () => { + const cases = [ + { + name: 'paragraphs with mixed alignments', + snapshot: 'display-alignment-paragraphs.png', + html: [ + '', + '

Left aligned (default)

', + '

Center aligned

', + '

Right aligned

', + '

Justified alignment. This needs a bit more text to properly visualize the justification spreading across the entire width of the container, ensuring both the left and right edges are perfectly flush against the margins.

', + '', + ].join(''), + }, + { + name: 'headings with mixed alignments', + snapshot: 'display-alignment-headings.png', + html: [ + '', + '

H2 Center

', + '

H4 Right

', + '
H6 Left
', + '', + ].join(''), + }, + { + name: 'blockquotes with independent alignments', + snapshot: 'display-alignment-blockquotes.png', + html: [ + '', + '
', + '

Quote left

', + '

Quote center

', + '

Quote right

', + '
', + '', + ].join(''), + }, + ]; + + for (const c of cases) { + test(c.name, async ({ page }) => { + await gotoTestEnrichedText(page); + await setEnrichedTextValue(page, c.html); + await expect(displayLocator(page)).toHaveScreenshot(c.snapshot); + }); + } +}); + +test.describe('visual: alignments for all list types', () => { + const cases = [ + { + name: 'unordered lists: left, center, right', + snapshot: 'display-alignment-ul.png', + html: [ + '', + '', + '', + '', + '', + ].join(''), + }, + { + name: 'ordered lists: left, center, right', + snapshot: 'display-alignment-ol.png', + html: [ + '', + '
  1. Left ordered 1
  2. Left ordered 2
', + '
  1. Center ordered 1
  2. Center ordered 2
', + '
  1. Right ordered 1
  2. Right ordered 2
', + '', + ].join(''), + }, + { + name: 'checkbox lists: left, center, right', + snapshot: 'display-alignment-checkbox.png', + html: [ + '', + '', + '', + '', + '', + ].join(''), + }, + { + name: 'complex mixed lists and layouts', + snapshot: 'display-alignment-mixed-lists.png', + html: [ + '', + '

A centered paragraph before lists

', + '
  1. Right ordered
', + '', + '', + '', + ].join(''), + }, + ]; + + for (const c of cases) { + test(c.name, async ({ page }) => { + await gotoTestEnrichedText(page); + await setEnrichedTextValue(page, c.html); + await expect(displayLocator(page)).toHaveScreenshot(c.snapshot); + }); + } +}); diff --git a/apps/example-web/src/testScreens/TestEnrichedText.tsx b/apps/example-web/src/testScreens/TestEnrichedText.tsx index 912031dc..bea3faa0 100644 --- a/apps/example-web/src/testScreens/TestEnrichedText.tsx +++ b/apps/example-web/src/testScreens/TestEnrichedText.tsx @@ -8,6 +8,7 @@ const INITIAL_VALUE = '

'; export function TestEnrichedText() { const [htmlInput, setHtmlInput] = useState(INITIAL_VALUE); const [value, setValue] = useState(INITIAL_VALUE); + const [isWide, setIsWide] = useState(false); return (
@@ -16,13 +17,23 @@ export function TestEnrichedText() { style={enrichedTextContainerStyle} > {value}
+ +