Просмотр исходного кода

Add accessible names to the editor editing field (#26678)

GitOrigin-RevId: 2ebed9db517c288450230675ae038d0cc3260a61
Rebeka Dekany 1 год назад
Родитель
Сommit
dc97da1276

+ 5 - 1
services/web/frontend/js/features/source-editor/extensions/index.ts

@@ -35,7 +35,7 @@ import importOverleafModules from '../../../../macros/import-overleaf-module.mac
 import { emptyLineFiller } from './empty-line-filler'
 import { emptyLineFiller } from './empty-line-filler'
 import { goToLinePanel } from './go-to-line'
 import { goToLinePanel } from './go-to-line'
 import { drawSelection } from './draw-selection'
 import { drawSelection } from './draw-selection'
-import { visual } from './visual/visual'
+import { sourceOnly, visual } from './visual/visual'
 import { inlineBackground } from './inline-background'
 import { inlineBackground } from './inline-background'
 import { indentationMarkers } from './indentation-markers'
 import { indentationMarkers } from './indentation-markers'
 import { codemirrorDevTools } from '../languages/latex/codemirror-dev-tools'
 import { codemirrorDevTools } from '../languages/latex/codemirror-dev-tools'
@@ -78,6 +78,10 @@ export const createExtensions = (options: Record<string, any>): Extension[] => [
   EditorState.allowMultipleSelections.of(true),
   EditorState.allowMultipleSelections.of(true),
   // A built-in extension that enables soft line wrapping.
   // A built-in extension that enables soft line wrapping.
   EditorView.lineWrapping,
   EditorView.lineWrapping,
+  sourceOnly(
+    options.visual,
+    EditorView.contentAttributes.of({ 'aria-label': 'Source Editor editing' })
+  ),
   // A built-in extension that re-indents input if the language defines an indentOnInput field in its language data.
   // A built-in extension that re-indents input if the language defines an indentOnInput field in its language data.
   indentOnInput(),
   indentOnInput(),
   lineWrappingIndentation(options.visual.visual),
   lineWrappingIndentation(options.visual.visual),

+ 1 - 0
services/web/frontend/js/features/source-editor/extensions/visual/visual.ts

@@ -178,4 +178,5 @@ const extension = (options: Options) => [
   showContentWhenParsed,
   showContentWhenParsed,
   pasteHtml,
   pasteHtml,
   tableGeneratorTheme,
   tableGeneratorTheme,
+  EditorView.contentAttributes.of({ 'aria-label': 'Visual Editor editing' }),
 ]
 ]