mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-27 14:59:27 +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.view = new EditorView(this.options.element, {
|
||||||
...this.options.editorProps,
|
...this.options.editorProps,
|
||||||
|
attributes: {
|
||||||
|
// add `role="textbox"` to the editor element
|
||||||
|
role: 'textbox',
|
||||||
|
...this.options.editorProps?.attributes,
|
||||||
|
},
|
||||||
dispatchTransaction: this.dispatchTransaction.bind(this),
|
dispatchTransaction: this.dispatchTransaction.bind(this),
|
||||||
state: EditorState.create({
|
state: EditorState.create({
|
||||||
doc,
|
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.
|
// `editor.view` is not yet available at this time.
|
||||||
// Therefore we will add all plugins and node views directly afterwards.
|
// Therefore we will add all plugins and node views directly afterwards.
|
||||||
const newState = this.state.reconfigure({
|
const newState = this.state.reconfigure({
|
||||||
|
Loading…
Reference in New Issue
Block a user