Improve accessibility on the editor DOM element (#5734)

* added accessibility attributes to the editor DOM element

* added changesets
This commit is contained in:
bdbch 2024-10-16 11:34:26 +02:00 committed by GitHub
parent 364231a1bd
commit a2eea24b5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/core": patch
---
Added role and aria-label attributes to the contenteditable field for better screenreader support and mouseless controls

View File

@ -352,6 +352,14 @@ export class Editor extends EventEmitter<EditorEvents> {
}),
})
// add `role="textbox"` to the editor element
this.view.dom.setAttribute('role', 'textbox')
// add aria-label to the editor element
if (!this.view.dom.getAttribute('aria-label')) {
this.view.dom.setAttribute('aria-label', 'Rich-Text Editor')
}
// `editor.view` is not yet available at this time.
// Therefore we will add all plugins and node views directly afterwards.
const newState = this.state.reconfigure({