Skip to content

Commit

Permalink
feat: accessibility improvements (#5758)
Browse files Browse the repository at this point in the history
  • Loading branch information
nperez0111 authored Nov 4, 2024
1 parent 830e683 commit e5228ea
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/core/src/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,18 @@ 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,
selection: selection || undefined,
}),
})

// 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({
Expand Down

0 comments on commit e5228ea

Please sign in to comment.