Path: blob/main/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/4import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';5import { IAccessibleViewImplementation } from '../../../../platform/accessibility/browser/accessibleViewRegistry.js';6import { IS_COMPOSITE_NOTEBOOK, NOTEBOOK_EDITOR_FOCUSED } from '../common/notebookContextKeys.js';7import { localize } from '../../../../nls.js';8import { ICodeEditor } from '../../../../editor/browser/editorBrowser.js';9import { AccessibleViewProviderId, AccessibleViewType, AccessibleContentProvider } from '../../../../platform/accessibility/browser/accessibleView.js';10import { AccessibilityVerbositySettingId } from '../../accessibility/browser/accessibilityConfiguration.js';11import { IEditorService } from '../../../services/editor/common/editorService.js';12import { IVisibleEditorPane } from '../../../common/editor.js';13import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';14import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';1516export class NotebookAccessibilityHelp implements IAccessibleViewImplementation {17readonly priority = 105;18readonly name = 'notebook';19readonly when = ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, IS_COMPOSITE_NOTEBOOK.negate());20readonly type: AccessibleViewType = AccessibleViewType.Help;21getProvider(accessor: ServicesAccessor) {22const activeEditor = accessor.get(ICodeEditorService).getActiveCodeEditor()23|| accessor.get(ICodeEditorService).getFocusedCodeEditor()24|| accessor.get(IEditorService).activeEditorPane;2526if (!activeEditor) {27return;28}29return getAccessibilityHelpProvider(accessor, activeEditor);30}31}3233function getAccessibilityHelpText(): string {34return [35localize('notebook.overview', 'The notebook view is a collection of code and markdown cells. Code cells can be executed and will produce output directly below the cell.'),36localize('notebook.cell.edit', 'The Edit Cell command{0} will focus on the cell input.', '<keybinding:notebook.cell.edit>'),37localize('notebook.cell.quitEdit', 'The Quit Edit command{0} will set focus on the cell container. The default (Escape) key may need to be pressed twice first exit the virtual cursor if active.', '<keybinding:notebook.cell.quitEdit>'),38localize('notebook.cell.focusInOutput', 'The Focus Output command{0} will set focus in the cell\'s output.', '<keybinding:notebook.cell.focusInOutput>'),39localize('notebook.focusNextEditor', 'The Focus Next Cell Editor command{0} will set focus in the next cell\'s editor.', '<keybinding:notebook.focusNextEditor>'),40localize('notebook.focusPreviousEditor', 'The Focus Previous Cell Editor command{0} will set focus in the previous cell\'s editor.', '<keybinding:notebook.focusPreviousEditor>'),41localize('notebook.cellNavigation', 'The up and down arrows will also move focus between cells while focused on the outer cell container.'),42localize('notebook.cell.executeAndFocusContainer', 'The Execute Cell command{0} executes the cell that currently has focus.', '<keybinding:notebook.cell.executeAndFocusContainer>'),43localize('notebook.cell.insertCodeCellBelowAndFocusContainer', 'The Insert Cell Above{0} and Below{1} commands will create new empty code cells.', '<keybinding:notebook.cell.insertCodeCellAbove>', '<keybinding:notebook.cell.insertCodeCellBelow>'),44localize('notebook.changeCellType', 'The Change Cell to Code/Markdown commands are used to switch between cell types.')45].join('\n');46}4748function getAccessibilityHelpProvider(accessor: ServicesAccessor, editor: ICodeEditor | IVisibleEditorPane) {49const helpText = getAccessibilityHelpText();50return new AccessibleContentProvider(51AccessibleViewProviderId.Notebook,52{ type: AccessibleViewType.Help },53() => helpText,54() => editor.focus(),55AccessibilityVerbositySettingId.Notebook,56);57}585960