feat: accessibility improvements (#5758)

This commit is contained in:
Nick Perez 2024-11-04 13:49:58 +01:00 committed by GitHub
parent 830e683dde
commit e5228ea6be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -360,6 +360,11 @@ export class Editor extends EventEmitter<EditorEvents> {
this.view = new EditorView(this.options.element, {
...this.options.editorProps,
attributes: {
// add `role="textbox"` to the editor element
role: 'textbox',
...this.options.editorProps?.attributes,
},
dispatchTransaction: this.dispatchTransaction.bind(this),
state: EditorState.create({
doc,
@ -367,14 +372,6 @@ 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({