mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 03:39:01 +08:00
feat: accessibility improvements (#5758)
This commit is contained in:
parent
830e683dde
commit
e5228ea6be
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user