Skip to content

Commit db361ad

Browse files
committed
✨(frontend) set empty alt for decorative images in blocknote editor
ensure decorative images have empty alt to comply with RGAA 1.2 accessibility Signed-off-by: Cyril <[email protected]>
1 parent 0cf8b9d commit db361ad

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ and this project adheres to
1717
- #1262
1818
- #1244
1919
- #1270
20+
- #1282
2021

2122
### Fixed
2223

2324
- 🐛(makefile) Windows compatibility fix for Docker volume mounting #1264
2425
- 🐛(minio) fix user permission error with Minio and Windows #1264
2526

26-
2727
## [3.5.0] - 2025-07-31
2828

2929
### Added

src/frontend/apps/e2e/__tests__/app-impress/config.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ test.describe('Config', () => {
4343
path.join(__dirname, 'assets/logo-suite-numerique.png'),
4444
);
4545

46-
const image = page.getByRole('img', { name: 'logo-suite-numerique.png' });
46+
const image = page
47+
.locator('.--docs--editor-container img.bn-visual-media')
48+
.first();
4749

4850
await expect(image).toBeVisible();
4951

src/frontend/apps/e2e/__tests__/app-impress/doc-editor.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ test.describe('Doc Editor', () => {
272272
path.join(__dirname, 'assets/logo-suite-numerique.png'),
273273
);
274274

275-
const image = page.getByRole('img', { name: 'logo-suite-numerique.png' });
275+
const image = page
276+
.locator('.--docs--editor-container img.bn-visual-media')
277+
.first();
276278

277279
await expect(image).toBeVisible();
278280

src/frontend/apps/e2e/__tests__/app-impress/doc-export.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ test.describe('Doc Export', () => {
122122
const fileChooser = await fileChooserPromise;
123123
await fileChooser.setFiles(path.join(__dirname, 'assets/test.svg'));
124124

125-
const image = page.getByRole('img', { name: 'test.svg' });
125+
const image = page
126+
.locator('.--docs--editor-container img.bn-visual-media')
127+
.first();
126128

127129
await expect(image).toBeVisible();
128130

@@ -182,7 +184,9 @@ test.describe('Doc Export', () => {
182184
const fileChooser = await fileChooserPromise;
183185
await fileChooser.setFiles(path.join(__dirname, 'assets/test.svg'));
184186

185-
const image = page.getByRole('img', { name: 'test.svg' });
187+
const image = page
188+
.locator('.--docs--editor-container img.bn-visual-media')
189+
.first();
186190

187191
await expect(image).toBeVisible();
188192

src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,40 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => {
169169
};
170170
}, [setEditor, editor]);
171171

172+
// Accessibility: make all images decorative by default
173+
useEffect(() => {
174+
if (!editor) {
175+
return;
176+
}
177+
178+
const applyDecorativeAlt = () => {
179+
const imgs = document.querySelectorAll<HTMLImageElement>(
180+
'.--docs--editor-container img.bn-visual-media',
181+
);
182+
imgs.forEach((img) => {
183+
img.setAttribute('alt', '');
184+
img.setAttribute('role', 'presentation');
185+
img.setAttribute('aria-hidden', 'true');
186+
});
187+
};
188+
189+
applyDecorativeAlt();
190+
191+
const unsubscribe = editor.onChange(() => {
192+
applyDecorativeAlt();
193+
});
194+
195+
return () => {
196+
try {
197+
if (typeof unsubscribe === 'function') {
198+
unsubscribe();
199+
}
200+
} catch {
201+
/* no-op */
202+
}
203+
};
204+
}, [editor]);
205+
172206
return (
173207
<Box
174208
$padding={{ top: 'md' }}

0 commit comments

Comments
 (0)