Skip to content

Commit 9f90caa

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 9f90caa

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
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/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)