Skip to content

Commit

Permalink
Improve accessibility on the editor DOM element (#5734)
Browse files Browse the repository at this point in the history
* added accessibility attributes to the editor DOM element

* added changesets
  • Loading branch information
bdbch authored Oct 16, 2024
1 parent 364231a commit a2eea24
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/soft-peaches-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tiptap/core": patch
---

Added role and aria-label attributes to the contenteditable field for better screenreader support and mouseless controls
8 changes: 8 additions & 0 deletions packages/core/src/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit a2eea24

Please sign in to comment.