Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
6
import { IAccessibleViewImplementation } from '../../../../platform/accessibility/browser/accessibleViewRegistry.js';
7
import { IS_COMPOSITE_NOTEBOOK, NOTEBOOK_EDITOR_FOCUSED } from '../common/notebookContextKeys.js';
8
import { localize } from '../../../../nls.js';
9
import { ICodeEditor } from '../../../../editor/browser/editorBrowser.js';
10
import { AccessibleViewProviderId, AccessibleViewType, AccessibleContentProvider } from '../../../../platform/accessibility/browser/accessibleView.js';
11
import { AccessibilityVerbositySettingId } from '../../accessibility/browser/accessibilityConfiguration.js';
12
import { IEditorService } from '../../../services/editor/common/editorService.js';
13
import { IVisibleEditorPane } from '../../../common/editor.js';
14
import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';
15
import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';
16
17
export class NotebookAccessibilityHelp implements IAccessibleViewImplementation {
18
readonly priority = 105;
19
readonly name = 'notebook';
20
readonly when = ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, IS_COMPOSITE_NOTEBOOK.negate());
21
readonly type: AccessibleViewType = AccessibleViewType.Help;
22
getProvider(accessor: ServicesAccessor) {
23
const activeEditor = accessor.get(ICodeEditorService).getActiveCodeEditor()
24
|| accessor.get(ICodeEditorService).getFocusedCodeEditor()
25
|| accessor.get(IEditorService).activeEditorPane;
26
27
if (!activeEditor) {
28
return;
29
}
30
return getAccessibilityHelpProvider(accessor, activeEditor);
31
}
32
}
33
34
function getAccessibilityHelpText(): string {
35
return [
36
localize('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.'),
37
localize('notebook.cell.edit', 'The Edit Cell command{0} will focus on the cell input.', '<keybinding:notebook.cell.edit>'),
38
localize('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>'),
39
localize('notebook.cell.focusInOutput', 'The Focus Output command{0} will set focus in the cell\'s output.', '<keybinding:notebook.cell.focusInOutput>'),
40
localize('notebook.focusNextEditor', 'The Focus Next Cell Editor command{0} will set focus in the next cell\'s editor.', '<keybinding:notebook.focusNextEditor>'),
41
localize('notebook.focusPreviousEditor', 'The Focus Previous Cell Editor command{0} will set focus in the previous cell\'s editor.', '<keybinding:notebook.focusPreviousEditor>'),
42
localize('notebook.cellNavigation', 'The up and down arrows will also move focus between cells while focused on the outer cell container.'),
43
localize('notebook.cell.executeAndFocusContainer', 'The Execute Cell command{0} executes the cell that currently has focus.', '<keybinding:notebook.cell.executeAndFocusContainer>'),
44
localize('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>'),
45
localize('notebook.changeCellType', 'The Change Cell to Code/Markdown commands are used to switch between cell types.')
46
].join('\n');
47
}
48
49
function getAccessibilityHelpProvider(accessor: ServicesAccessor, editor: ICodeEditor | IVisibleEditorPane) {
50
const helpText = getAccessibilityHelpText();
51
return new AccessibleContentProvider(
52
AccessibleViewProviderId.Notebook,
53
{ type: AccessibleViewType.Help },
54
() => helpText,
55
() => editor.focus(),
56
AccessibilityVerbositySettingId.Notebook,
57
);
58
}
59
60