Merge pull request #188294 from microsoft/merogge/screen-reader-message

inform screen reader user how to enter optimized mode in editor
This commit is contained in:
Megan Rogge
2023-07-19 10:57:57 -07:00
committed by GitHub
4 changed files with 34 additions and 7 deletions

View File

@@ -35,6 +35,7 @@ import { TokenizationRegistry } from 'vs/editor/common/languages';
import { ColorId, ITokenPresentation } from 'vs/editor/common/encodedTokenAttributes'; import { ColorId, ITokenPresentation } from 'vs/editor/common/encodedTokenAttributes';
import { Color } from 'vs/base/common/color'; import { Color } from 'vs/base/common/color';
import { IME } from 'vs/base/common/ime'; import { IME } from 'vs/base/common/ime';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
export interface IVisibleRangeProvider { export interface IVisibleRangeProvider {
visibleRangeForPosition(position: Position): HorizontalPosition | null; visibleRangeForPosition(position: Position): HorizontalPosition | null;
@@ -140,7 +141,12 @@ export class TextAreaHandler extends ViewPart {
public readonly textAreaCover: FastDomNode<HTMLElement>; public readonly textAreaCover: FastDomNode<HTMLElement>;
private readonly _textAreaInput: TextAreaInput; private readonly _textAreaInput: TextAreaInput;
constructor(context: ViewContext, viewController: ViewController, visibleRangeProvider: IVisibleRangeProvider) { constructor(
context: ViewContext,
viewController: ViewController,
visibleRangeProvider: IVisibleRangeProvider,
@IKeybindingService private readonly _keybindingService: IKeybindingService
) {
super(context); super(context);
this._viewController = viewController; this._viewController = viewController;
@@ -553,7 +559,21 @@ export class TextAreaHandler extends ViewPart {
private _getAriaLabel(options: IComputedEditorOptions): string { private _getAriaLabel(options: IComputedEditorOptions): string {
const accessibilitySupport = options.get(EditorOption.accessibilitySupport); const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
if (accessibilitySupport === AccessibilitySupport.Disabled) { if (accessibilitySupport === AccessibilitySupport.Disabled) {
return nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press {0} for options.", platform.isLinux ? 'Shift+Alt+F1' : 'Alt+F1');
const toggleKeybindingLabel = this._keybindingService.lookupKeybinding('editor.action.toggleScreenReaderAccessibilityMode')?.getAriaLabel();
const runCommandKeybindingLabel = this._keybindingService.lookupKeybinding('workbench.action.showCommands')?.getAriaLabel();
const keybindingEditorKeybindingLabel = this._keybindingService.lookupKeybinding('workbench.action.openGlobalKeybindings')?.getAriaLabel();
const editorNotAccessibleMessage = nls.localize('accessibilityModeOff', "The editor is not accessible at this time.");
if (toggleKeybindingLabel) {
return nls.localize('accessibilityOffAriaLabel', "{0} To enable screen reader optimized mode, use {1}", editorNotAccessibleMessage, toggleKeybindingLabel);
} else if (runCommandKeybindingLabel) {
return nls.localize('accessibilityOffAriaLabelNoKb', "{0} To enable screen reader optimized mode, open the quick pick with {1} and run the command Toggle Screen Reader Accessibility Mode, which is currently not triggerable via keyboard.", editorNotAccessibleMessage, runCommandKeybindingLabel);
} else if (keybindingEditorKeybindingLabel) {
return nls.localize('accessibilityOffAriaLabelNoKbs', "{0} Please assign a keybinding for the command Toggle Screen Reader Accessibility Mode by accessing the keybindings editor with {1} and run it.", editorNotAccessibleMessage, keybindingEditorKeybindingLabel);
} else {
// SOS
return editorNotAccessibleMessage;
}
} }
return options.get(EditorOption.ariaLabel); return options.get(EditorOption.ariaLabel);
} }

View File

@@ -54,6 +54,7 @@ import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
import { WhitespaceOverlay } from 'vs/editor/browser/viewParts/whitespace/whitespace'; import { WhitespaceOverlay } from 'vs/editor/browser/viewParts/whitespace/whitespace';
import { GlyphMarginWidgets } from 'vs/editor/browser/viewParts/glyphMargin/glyphMargin'; import { GlyphMarginWidgets } from 'vs/editor/browser/viewParts/glyphMargin/glyphMargin';
import { GlyphMarginLane } from 'vs/editor/common/model'; import { GlyphMarginLane } from 'vs/editor/common/model';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export interface IContentWidgetData { export interface IContentWidgetData {
@@ -106,7 +107,8 @@ export class View extends ViewEventHandler {
colorTheme: IColorTheme, colorTheme: IColorTheme,
model: IViewModel, model: IViewModel,
userInputEvents: ViewUserInputEvents, userInputEvents: ViewUserInputEvents,
overflowWidgetsDomNode: HTMLElement | undefined overflowWidgetsDomNode: HTMLElement | undefined,
@IInstantiationService private readonly _instantiationService: IInstantiationService
) { ) {
super(); super();
this._selections = [new Selection(1, 1, 1, 1)]; this._selections = [new Selection(1, 1, 1, 1)];
@@ -123,7 +125,7 @@ export class View extends ViewEventHandler {
this._viewParts = []; this._viewParts = [];
// Keyboard handler // Keyboard handler
this._textAreaHandler = new TextAreaHandler(this._context, viewController, this._createTextAreaHandlerHelper()); this._textAreaHandler = this._instantiationService.createInstance(TextAreaHandler, this._context, viewController, this._createTextAreaHandlerHelper());
this._viewParts.push(this._textAreaHandler); this._viewParts.push(this._textAreaHandler);
// These two dom nodes must be constructed up front, since references are needed in the layout provider (scrolling & co.) // These two dom nodes must be constructed up front, since references are needed in the layout provider (scrolling & co.)

View File

@@ -1853,7 +1853,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
this._themeService.getColorTheme(), this._themeService.getColorTheme(),
viewModel, viewModel,
viewUserInputEvents, viewUserInputEvents,
this._overflowWidgetsDomNode this._overflowWidgetsDomNode,
this._instantiationService
); );
return [view, true]; return [view, true];

View File

@@ -22,11 +22,15 @@ class ToggleScreenReaderMode extends Action2 {
id: 'editor.action.toggleScreenReaderAccessibilityMode', id: 'editor.action.toggleScreenReaderAccessibilityMode',
title: { value: nls.localize('toggleScreenReaderMode', "Toggle Screen Reader Accessibility Mode"), original: 'Toggle Screen Reader Accessibility Mode' }, title: { value: nls.localize('toggleScreenReaderMode', "Toggle Screen Reader Accessibility Mode"), original: 'Toggle Screen Reader Accessibility Mode' },
f1: true, f1: true,
keybinding: { keybinding: [{
primary: KeyMod.CtrlCmd | KeyCode.KeyE, primary: KeyMod.CtrlCmd | KeyCode.KeyE,
weight: KeybindingWeight.WorkbenchContrib + 10, weight: KeybindingWeight.WorkbenchContrib + 10,
when: accessibilityHelpIsShown when: accessibilityHelpIsShown
} },
{
primary: KeyMod.Alt | KeyCode.F3,
weight: KeybindingWeight.WorkbenchContrib + 10,
}]
}); });
} }