@codingame/monaco-vscode-accessibility-service-override 5.2.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accessibility.js +2 -2
- package/assets/success.mp3 +0 -0
- package/package.json +2 -2
- package/vscode/src/vs/platform/accessibilitySignal/browser/media/all.mp3.js +1 -0
- package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibility.contribution.js +17 -20
- package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibilityStatus.js +5 -3
- package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibleView.js +864 -0
- package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibleViewContributions.js +39 -0
- package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibleViewKeybindingResolver.js +35 -0
- package/vscode/src/vs/workbench/contrib/accessibility/browser/extensionAccesibilityHelp.contribution.js +66 -0
- package/vscode/src/vs/workbench/contrib/accessibility/browser/unfocusedViewDimmingContribution.js +4 -3
- package/vscode/src/vs/workbench/contrib/accessibilitySignals/browser/accessibilitySignal.contribution.js +4 -3
- package/vscode/src/vs/workbench/contrib/accessibilitySignals/browser/editorTextPropertySignalsContribution.js +5 -20
- package/vscode/src/vs/workbench/contrib/accessibilitySignals/browser/openDiffEditorAnnouncement.js +3 -2
- package/vscode/src/vs/workbench/contrib/accessibilitySignals/browser/saveAccessibilitySignal.js +2 -1
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.js +9 -6
- package/vscode/src/vs/workbench/services/accessibility/common/accessibleViewInformationService.js +2 -1
- package/vscode/src/vs/workbench/contrib/accessibility/browser/audioCueConfiguration.js +0 -231
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { getActiveWindow, addDisposableListener, EventType, isActiveElement } from 'vscode/vscode/vs/base/browser/dom';
|
|
3
|
+
import { StandardKeyboardEvent } from 'vscode/vscode/vs/base/browser/keyboardEvent';
|
|
4
|
+
import { ActionsOrientation } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionbar';
|
|
5
|
+
import { alert } from 'vscode/vscode/vs/base/browser/ui/aria/aria';
|
|
6
|
+
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
7
|
+
import { KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
8
|
+
import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
9
|
+
import marked_1 from 'vscode/external/vscode-marked/lib/marked.esm.js';
|
|
10
|
+
import { isMacintosh, isWindows } from 'vscode/vscode/vs/base/common/platform';
|
|
11
|
+
import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
|
|
12
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
13
|
+
import { EditorExtensionsRegistry } from 'vscode/vscode/vs/editor/browser/editorExtensions';
|
|
14
|
+
import { CodeEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/codeEditor/codeEditorWidget';
|
|
15
|
+
import { Position } from 'vscode/vscode/vs/editor/common/core/position';
|
|
16
|
+
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
17
|
+
import { AccessibilityHelpNLS } from 'vscode/vscode/vs/editor/common/standaloneStrings';
|
|
18
|
+
import { CodeActionController } from 'vscode/vscode/vs/editor/contrib/codeAction/browser/codeActionController';
|
|
19
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
20
|
+
import { AdvancedContentProvider, AccessibleViewProviderId, ExtensionContentProvider, AccessibleViewType } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleView';
|
|
21
|
+
import { ACCESSIBLE_VIEW_SHOWN_STORAGE_PREFIX } from 'vscode/vscode/vs/platform/accessibility/common/accessibility';
|
|
22
|
+
import { IAccessibilityService } from 'vscode/vscode/vs/platform/accessibility/common/accessibility.service';
|
|
23
|
+
import { createAndFillInActionBarActions } from 'vscode/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
|
|
24
|
+
import { WorkbenchToolBar } from 'vscode/vscode/vs/platform/actions/browser/toolbar';
|
|
25
|
+
import { MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
26
|
+
import { IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions.service';
|
|
27
|
+
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
|
|
28
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
29
|
+
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
30
|
+
import { IContextViewService } from 'vscode/vscode/vs/platform/contextview/browser/contextView.service';
|
|
31
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
32
|
+
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding.service';
|
|
33
|
+
import { ResultKind } from 'vscode/vscode/vs/platform/keybinding/common/keybindingResolver';
|
|
34
|
+
import { ILayoutService } from 'vscode/vscode/vs/platform/layout/browser/layoutService.service';
|
|
35
|
+
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener.service';
|
|
36
|
+
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
37
|
+
import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
38
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
39
|
+
import { accessibilityHelpIsShown, accessibleViewIsShown, accessibleViewSupportsNavigation, accessibleViewVerbosityEnabled, accessibleViewGoToSymbolSupported, accessibleViewCurrentProviderId, accessibleViewInCodeBlock, accessibleViewContainsCodeBlocks, accessibleViewOnLastLine, AccessibilityWorkbenchSettingId, AccessibilityVerbositySettingId } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
|
|
40
|
+
import { resolveContentAndKeybindingItems } from './accessibleViewKeybindingResolver.js';
|
|
41
|
+
import { AccessibilityCommandId } from 'vscode/vscode/vs/workbench/contrib/accessibility/common/accessibilityCommands';
|
|
42
|
+
import { IChatCodeBlockContextProviderService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
43
|
+
import { getSimpleEditorOptions } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
|
|
44
|
+
|
|
45
|
+
const _moduleId = "vs/workbench/contrib/accessibility/browser/accessibleView";
|
|
46
|
+
var DIMENSIONS;
|
|
47
|
+
( ((function(DIMENSIONS) {
|
|
48
|
+
DIMENSIONS[DIMENSIONS["MAX_WIDTH"] = 600] = "MAX_WIDTH";
|
|
49
|
+
})(DIMENSIONS || (DIMENSIONS = {}))));
|
|
50
|
+
let AccessibleView = class AccessibleView extends Disposable {
|
|
51
|
+
get editorWidget() { return this._editorWidget; }
|
|
52
|
+
constructor(_openerService, _instantiationService, _configurationService, _modelService, _contextViewService, _contextKeyService, _accessibilityService, _keybindingService, _layoutService, _menuService, _commandService, _codeBlockContextProviderService, _storageService, _quickInputService) {
|
|
53
|
+
super();
|
|
54
|
+
this._openerService = _openerService;
|
|
55
|
+
this._instantiationService = _instantiationService;
|
|
56
|
+
this._configurationService = _configurationService;
|
|
57
|
+
this._modelService = _modelService;
|
|
58
|
+
this._contextViewService = _contextViewService;
|
|
59
|
+
this._contextKeyService = _contextKeyService;
|
|
60
|
+
this._accessibilityService = _accessibilityService;
|
|
61
|
+
this._keybindingService = _keybindingService;
|
|
62
|
+
this._layoutService = _layoutService;
|
|
63
|
+
this._menuService = _menuService;
|
|
64
|
+
this._commandService = _commandService;
|
|
65
|
+
this._codeBlockContextProviderService = _codeBlockContextProviderService;
|
|
66
|
+
this._storageService = _storageService;
|
|
67
|
+
this._quickInputService = _quickInputService;
|
|
68
|
+
this._inQuickPick = false;
|
|
69
|
+
this._accessiblityHelpIsShown = accessibilityHelpIsShown.bindTo(this._contextKeyService);
|
|
70
|
+
this._accessibleViewIsShown = accessibleViewIsShown.bindTo(this._contextKeyService);
|
|
71
|
+
this._accessibleViewSupportsNavigation = accessibleViewSupportsNavigation.bindTo(this._contextKeyService);
|
|
72
|
+
this._accessibleViewVerbosityEnabled = accessibleViewVerbosityEnabled.bindTo(this._contextKeyService);
|
|
73
|
+
this._accessibleViewGoToSymbolSupported = accessibleViewGoToSymbolSupported.bindTo(this._contextKeyService);
|
|
74
|
+
this._accessibleViewCurrentProviderId = accessibleViewCurrentProviderId.bindTo(this._contextKeyService);
|
|
75
|
+
this._accessibleViewInCodeBlock = accessibleViewInCodeBlock.bindTo(this._contextKeyService);
|
|
76
|
+
this._accessibleViewContainsCodeBlocks = accessibleViewContainsCodeBlocks.bindTo(this._contextKeyService);
|
|
77
|
+
this._onLastLine = accessibleViewOnLastLine.bindTo(this._contextKeyService);
|
|
78
|
+
this._container = document.createElement('div');
|
|
79
|
+
this._container.classList.add('accessible-view');
|
|
80
|
+
if (this._configurationService.getValue(AccessibilityWorkbenchSettingId.HideAccessibleView)) {
|
|
81
|
+
this._container.classList.add('hide');
|
|
82
|
+
}
|
|
83
|
+
const codeEditorWidgetOptions = {
|
|
84
|
+
contributions: EditorExtensionsRegistry.getEditorContributions().filter(c => c.id !== CodeActionController.ID)
|
|
85
|
+
};
|
|
86
|
+
const titleBar = document.createElement('div');
|
|
87
|
+
titleBar.classList.add('accessible-view-title-bar');
|
|
88
|
+
this._title = document.createElement('div');
|
|
89
|
+
this._title.classList.add('accessible-view-title');
|
|
90
|
+
titleBar.appendChild(this._title);
|
|
91
|
+
const actionBar = document.createElement('div');
|
|
92
|
+
actionBar.classList.add('accessible-view-action-bar');
|
|
93
|
+
titleBar.appendChild(actionBar);
|
|
94
|
+
this._container.appendChild(titleBar);
|
|
95
|
+
this._toolbar = this._register(_instantiationService.createInstance(WorkbenchToolBar, actionBar, { orientation: ActionsOrientation.HORIZONTAL }));
|
|
96
|
+
this._toolbar.context = { viewId: 'accessibleView' };
|
|
97
|
+
const toolbarElt = this._toolbar.getElement();
|
|
98
|
+
toolbarElt.tabIndex = 0;
|
|
99
|
+
const editorOptions = {
|
|
100
|
+
...getSimpleEditorOptions(this._configurationService),
|
|
101
|
+
lineDecorationsWidth: 6,
|
|
102
|
+
dragAndDrop: false,
|
|
103
|
+
cursorWidth: 1,
|
|
104
|
+
wrappingStrategy: 'advanced',
|
|
105
|
+
wrappingIndent: 'none',
|
|
106
|
+
padding: { top: 2, bottom: 2 },
|
|
107
|
+
quickSuggestions: false,
|
|
108
|
+
renderWhitespace: 'none',
|
|
109
|
+
dropIntoEditor: { enabled: false },
|
|
110
|
+
readOnly: true,
|
|
111
|
+
fontFamily: 'var(--monaco-monospace-font)'
|
|
112
|
+
};
|
|
113
|
+
this._editorWidget = this._register(this._instantiationService.createInstance(CodeEditorWidget, this._container, editorOptions, codeEditorWidgetOptions));
|
|
114
|
+
this._register(this._accessibilityService.onDidChangeScreenReaderOptimized(() => {
|
|
115
|
+
if (this._currentProvider && this._accessiblityHelpIsShown.get()) {
|
|
116
|
+
this.show(this._currentProvider);
|
|
117
|
+
}
|
|
118
|
+
}));
|
|
119
|
+
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
|
120
|
+
if (this._currentProvider instanceof AdvancedContentProvider && e.affectsConfiguration(this._currentProvider.verbositySettingKey)) {
|
|
121
|
+
if (this._accessiblityHelpIsShown.get()) {
|
|
122
|
+
this.show(this._currentProvider);
|
|
123
|
+
}
|
|
124
|
+
this._accessibleViewVerbosityEnabled.set(this._configurationService.getValue(this._currentProvider.verbositySettingKey));
|
|
125
|
+
this._updateToolbar(this._currentProvider.actions, this._currentProvider.options.type);
|
|
126
|
+
}
|
|
127
|
+
if (e.affectsConfiguration(AccessibilityWorkbenchSettingId.HideAccessibleView)) {
|
|
128
|
+
this._container.classList.toggle('hide', this._configurationService.getValue(AccessibilityWorkbenchSettingId.HideAccessibleView));
|
|
129
|
+
}
|
|
130
|
+
}));
|
|
131
|
+
this._register(this._editorWidget.onDidDispose(() => this._resetContextKeys()));
|
|
132
|
+
this._register(this._editorWidget.onDidChangeCursorPosition(() => {
|
|
133
|
+
this._onLastLine.set(this._editorWidget.getPosition()?.lineNumber === this._editorWidget.getModel()?.getLineCount());
|
|
134
|
+
}));
|
|
135
|
+
this._register(this._editorWidget.onDidChangeCursorPosition(() => {
|
|
136
|
+
const cursorPosition = this._editorWidget.getPosition()?.lineNumber;
|
|
137
|
+
if (this._codeBlocks && cursorPosition !== undefined) {
|
|
138
|
+
const inCodeBlock = this._codeBlocks.find(c => c.startLine <= cursorPosition && c.endLine >= cursorPosition) !== undefined;
|
|
139
|
+
this._accessibleViewInCodeBlock.set(inCodeBlock);
|
|
140
|
+
}
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
_resetContextKeys() {
|
|
144
|
+
this._accessiblityHelpIsShown.reset();
|
|
145
|
+
this._accessibleViewIsShown.reset();
|
|
146
|
+
this._accessibleViewSupportsNavigation.reset();
|
|
147
|
+
this._accessibleViewVerbosityEnabled.reset();
|
|
148
|
+
this._accessibleViewGoToSymbolSupported.reset();
|
|
149
|
+
this._accessibleViewCurrentProviderId.reset();
|
|
150
|
+
}
|
|
151
|
+
getPosition(id) {
|
|
152
|
+
if (!id || !this._lastProvider || this._lastProvider.id !== id) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
return this._editorWidget.getPosition() || undefined;
|
|
156
|
+
}
|
|
157
|
+
setPosition(position, reveal) {
|
|
158
|
+
this._editorWidget.setPosition(position);
|
|
159
|
+
if (reveal) {
|
|
160
|
+
this._editorWidget.revealPosition(position);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
getCodeBlockContext() {
|
|
164
|
+
const position = this._editorWidget.getPosition();
|
|
165
|
+
if (!this._codeBlocks?.length || !position) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const codeBlockIndex = this._codeBlocks?.findIndex(c => c.startLine <= position?.lineNumber && c.endLine >= position?.lineNumber);
|
|
169
|
+
const codeBlock = codeBlockIndex !== undefined && codeBlockIndex > -1 ? this._codeBlocks[codeBlockIndex] : undefined;
|
|
170
|
+
if (!codeBlock || codeBlockIndex === undefined) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
return { code: codeBlock.code, languageId: codeBlock.languageId, codeBlockIndex, element: undefined };
|
|
174
|
+
}
|
|
175
|
+
navigateToCodeBlock(type) {
|
|
176
|
+
const position = this._editorWidget.getPosition();
|
|
177
|
+
if (!this._codeBlocks?.length || !position) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
let codeBlock;
|
|
181
|
+
const codeBlocks = this._codeBlocks.slice();
|
|
182
|
+
if (type === 'previous') {
|
|
183
|
+
codeBlock = codeBlocks.reverse().find(c => c.endLine < position.lineNumber);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
codeBlock = codeBlocks.find(c => c.startLine > position.lineNumber);
|
|
187
|
+
}
|
|
188
|
+
if (!codeBlock) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this.setPosition(( (new Position(codeBlock.startLine, 1))), true);
|
|
192
|
+
}
|
|
193
|
+
showLastProvider(id) {
|
|
194
|
+
if (!this._lastProvider || this._lastProvider.options.id !== id) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
this.show(this._lastProvider);
|
|
198
|
+
}
|
|
199
|
+
show(provider, symbol, showAccessibleViewHelp, position) {
|
|
200
|
+
provider = provider ?? this._currentProvider;
|
|
201
|
+
if (!provider) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
provider.onOpen?.();
|
|
205
|
+
let viewContainer;
|
|
206
|
+
const delegate = {
|
|
207
|
+
getAnchor: () => { return { x: (getActiveWindow().innerWidth / 2) - ((Math.min(this._layoutService.activeContainerDimension.width * 0.62 , DIMENSIONS.MAX_WIDTH)) / 2), y: this._layoutService.activeContainerOffset.quickPickTop }; },
|
|
208
|
+
render: (container) => {
|
|
209
|
+
viewContainer = container;
|
|
210
|
+
viewContainer.classList.add('accessible-view-container');
|
|
211
|
+
return this._render(provider, container, showAccessibleViewHelp);
|
|
212
|
+
},
|
|
213
|
+
onHide: () => {
|
|
214
|
+
if (!showAccessibleViewHelp) {
|
|
215
|
+
this._updateLastProvider();
|
|
216
|
+
this._currentProvider = undefined;
|
|
217
|
+
this._resetContextKeys();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
this._contextViewService.showContextView(delegate);
|
|
222
|
+
if (position) {
|
|
223
|
+
queueMicrotask(() => {
|
|
224
|
+
this._editorWidget.revealLine(position.lineNumber);
|
|
225
|
+
this._editorWidget.setSelection({ startLineNumber: position.lineNumber, startColumn: position.column, endLineNumber: position.lineNumber, endColumn: position.column });
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
if (symbol && this._currentProvider) {
|
|
229
|
+
this.showSymbol(this._currentProvider, symbol);
|
|
230
|
+
}
|
|
231
|
+
if (provider instanceof AdvancedContentProvider && provider.onDidRequestClearLastProvider) {
|
|
232
|
+
this._register(provider.onDidRequestClearLastProvider((id) => {
|
|
233
|
+
if (this._lastProvider?.options.id === id) {
|
|
234
|
+
this._lastProvider = undefined;
|
|
235
|
+
}
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
if (provider.options.id) {
|
|
239
|
+
this._lastProvider = provider;
|
|
240
|
+
}
|
|
241
|
+
if (provider.id === AccessibleViewProviderId.Chat) {
|
|
242
|
+
this._register(this._codeBlockContextProviderService.registerProvider({ getCodeBlockContext: () => this.getCodeBlockContext() }, 'accessibleView'));
|
|
243
|
+
}
|
|
244
|
+
if (provider instanceof ExtensionContentProvider) {
|
|
245
|
+
this._storageService.store(`${ACCESSIBLE_VIEW_SHOWN_STORAGE_PREFIX}${provider.id}`, true, StorageScope.APPLICATION, StorageTarget.USER);
|
|
246
|
+
}
|
|
247
|
+
if (provider.onDidChangeContent) {
|
|
248
|
+
this._register(provider.onDidChangeContent(() => {
|
|
249
|
+
if (viewContainer) {
|
|
250
|
+
this._render(provider, viewContainer, showAccessibleViewHelp);
|
|
251
|
+
}
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
previous() {
|
|
256
|
+
this._currentProvider?.previous?.();
|
|
257
|
+
}
|
|
258
|
+
next() {
|
|
259
|
+
this._currentProvider?.next?.();
|
|
260
|
+
}
|
|
261
|
+
_verbosityEnabled() {
|
|
262
|
+
if (!this._currentProvider) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
return this._currentProvider instanceof AdvancedContentProvider ? this._configurationService.getValue(this._currentProvider.verbositySettingKey) === true : this._storageService.getBoolean(`${ACCESSIBLE_VIEW_SHOWN_STORAGE_PREFIX}${this._currentProvider.id}`, StorageScope.APPLICATION, false);
|
|
266
|
+
}
|
|
267
|
+
goToSymbol() {
|
|
268
|
+
if (!this._currentProvider) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
this._instantiationService.createInstance(AccessibleViewSymbolQuickPick, this).show(this._currentProvider);
|
|
272
|
+
}
|
|
273
|
+
calculateCodeBlocks(markdown) {
|
|
274
|
+
if (this._currentProvider?.id !== AccessibleViewProviderId.Chat) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (this._currentProvider.options.language && this._currentProvider.options.language !== 'markdown') {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const lines = markdown.split('\n');
|
|
281
|
+
this._codeBlocks = [];
|
|
282
|
+
let inBlock = false;
|
|
283
|
+
let startLine = 0;
|
|
284
|
+
let languageId;
|
|
285
|
+
lines.forEach((line, i) => {
|
|
286
|
+
if (!inBlock && line.startsWith('```')) {
|
|
287
|
+
inBlock = true;
|
|
288
|
+
startLine = i + 1;
|
|
289
|
+
languageId = line.substring(3).trim();
|
|
290
|
+
}
|
|
291
|
+
else if (inBlock && line.endsWith('```')) {
|
|
292
|
+
inBlock = false;
|
|
293
|
+
const endLine = i;
|
|
294
|
+
const code = lines.slice(startLine, endLine).join('\n');
|
|
295
|
+
this._codeBlocks?.push({ startLine, endLine, code, languageId });
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
this._accessibleViewContainsCodeBlocks.set(this._codeBlocks.length > 0);
|
|
299
|
+
}
|
|
300
|
+
getSymbols() {
|
|
301
|
+
const provider = this._currentProvider instanceof AdvancedContentProvider ? this._currentProvider : undefined;
|
|
302
|
+
if (!this._currentContent || !provider) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const symbols = provider.getSymbols?.() || [];
|
|
306
|
+
if (symbols?.length) {
|
|
307
|
+
return symbols;
|
|
308
|
+
}
|
|
309
|
+
if (provider.options.language && provider.options.language !== 'markdown') {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const markdownTokens = marked_1.lexer(this._currentContent);
|
|
313
|
+
if (!markdownTokens) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
this._convertTokensToSymbols(markdownTokens, symbols);
|
|
317
|
+
return symbols.length ? symbols : undefined;
|
|
318
|
+
}
|
|
319
|
+
openHelpLink() {
|
|
320
|
+
if (!this._currentProvider?.options.readMoreUrl) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
this._openerService.open(( (URI.parse(this._currentProvider.options.readMoreUrl))));
|
|
324
|
+
}
|
|
325
|
+
configureKeybindings() {
|
|
326
|
+
this._inQuickPick = true;
|
|
327
|
+
const provider = this._updateLastProvider();
|
|
328
|
+
const items = provider?.options?.configureKeybindingItems;
|
|
329
|
+
if (!items) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const quickPick = this._quickInputService.createQuickPick();
|
|
333
|
+
this._register(quickPick);
|
|
334
|
+
quickPick.items = items;
|
|
335
|
+
quickPick.title = ( localizeWithPath(_moduleId, 0, 'Configure keybindings'));
|
|
336
|
+
quickPick.placeholder = ( localizeWithPath(_moduleId, 1, 'Select a command ID to configure a keybinding for it'));
|
|
337
|
+
quickPick.show();
|
|
338
|
+
quickPick.onDidAccept(async () => {
|
|
339
|
+
const item = quickPick.selectedItems[0];
|
|
340
|
+
if (item) {
|
|
341
|
+
await this._commandService.executeCommand('workbench.action.openGlobalKeybindings', item.id);
|
|
342
|
+
}
|
|
343
|
+
quickPick.dispose();
|
|
344
|
+
});
|
|
345
|
+
quickPick.onDidHide(() => {
|
|
346
|
+
if (!quickPick.selectedItems.length && provider) {
|
|
347
|
+
this.show(provider);
|
|
348
|
+
}
|
|
349
|
+
quickPick.dispose();
|
|
350
|
+
this._inQuickPick = false;
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
_convertTokensToSymbols(tokens, symbols) {
|
|
354
|
+
let firstListItem;
|
|
355
|
+
for (const token of tokens) {
|
|
356
|
+
let label = undefined;
|
|
357
|
+
if ('type' in token) {
|
|
358
|
+
switch (token.type) {
|
|
359
|
+
case 'heading':
|
|
360
|
+
case 'paragraph':
|
|
361
|
+
case 'code':
|
|
362
|
+
label = token.text;
|
|
363
|
+
break;
|
|
364
|
+
case 'list': {
|
|
365
|
+
const firstItem = token.items?.[0];
|
|
366
|
+
if (!firstItem) {
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
firstListItem = `- ${firstItem.text}`;
|
|
370
|
+
label = token.items?.map(i => i.text).join(', ');
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (label) {
|
|
376
|
+
symbols.push({ markdownToParse: label, label: ( localizeWithPath(_moduleId, 2, "({0}) {1}", token.type, label)), ariaLabel: ( localizeWithPath(_moduleId, 3, "({0}) {1}", token.type, label)), firstListItem });
|
|
377
|
+
firstListItem = undefined;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
showSymbol(provider, symbol) {
|
|
382
|
+
if (!this._currentContent) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
let lineNumber = symbol.lineNumber;
|
|
386
|
+
const markdownToParse = symbol.markdownToParse;
|
|
387
|
+
if (lineNumber === undefined && markdownToParse === undefined) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
if (lineNumber === undefined && markdownToParse) {
|
|
391
|
+
const index = this._currentContent.split('\n').findIndex(line => line.includes(markdownToParse.split('\n')[0]) || (symbol.firstListItem && line.includes(symbol.firstListItem))) ?? -1;
|
|
392
|
+
if (index >= 0) {
|
|
393
|
+
lineNumber = index + 1;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (lineNumber === undefined) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
this.show(provider, undefined, undefined, { lineNumber, column: 1 });
|
|
400
|
+
this._updateContextKeys(provider, true);
|
|
401
|
+
}
|
|
402
|
+
disableHint() {
|
|
403
|
+
if (!(this._currentProvider instanceof AdvancedContentProvider)) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
this._configurationService.updateValue(this._currentProvider?.verbositySettingKey, false);
|
|
407
|
+
alert(( localizeWithPath(
|
|
408
|
+
_moduleId,
|
|
409
|
+
4,
|
|
410
|
+
'{0} accessibility verbosity is now disabled',
|
|
411
|
+
this._currentProvider.verbositySettingKey
|
|
412
|
+
)));
|
|
413
|
+
}
|
|
414
|
+
_updateContextKeys(provider, shown) {
|
|
415
|
+
if (provider.options.type === AccessibleViewType.Help) {
|
|
416
|
+
this._accessiblityHelpIsShown.set(shown);
|
|
417
|
+
this._accessibleViewIsShown.reset();
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
this._accessibleViewIsShown.set(shown);
|
|
421
|
+
this._accessiblityHelpIsShown.reset();
|
|
422
|
+
}
|
|
423
|
+
this._accessibleViewSupportsNavigation.set(provider.next !== undefined || provider.previous !== undefined);
|
|
424
|
+
this._accessibleViewVerbosityEnabled.set(this._verbosityEnabled());
|
|
425
|
+
this._accessibleViewGoToSymbolSupported.set(this._goToSymbolsSupported() ? this.getSymbols()?.length > 0 : false);
|
|
426
|
+
}
|
|
427
|
+
_render(provider, container, showAccessibleViewHelp) {
|
|
428
|
+
this._currentProvider = provider;
|
|
429
|
+
this._accessibleViewCurrentProviderId.set(provider.id);
|
|
430
|
+
const verbose = this._verbosityEnabled();
|
|
431
|
+
const readMoreLink = provider.options.readMoreUrl ? ( localizeWithPath(
|
|
432
|
+
_moduleId,
|
|
433
|
+
5,
|
|
434
|
+
"\n\nOpen a browser window with more information related to accessibility<keybinding:{0}>.",
|
|
435
|
+
AccessibilityCommandId.AccessibilityHelpOpenHelpLink
|
|
436
|
+
)) : '';
|
|
437
|
+
let disableHelpHint = '';
|
|
438
|
+
if (provider instanceof AdvancedContentProvider && provider.options.type === AccessibleViewType.Help && verbose) {
|
|
439
|
+
disableHelpHint = this._getDisableVerbosityHint();
|
|
440
|
+
}
|
|
441
|
+
const accessibilitySupport = this._accessibilityService.isScreenReaderOptimized();
|
|
442
|
+
let message = '';
|
|
443
|
+
if (provider.options.type === AccessibleViewType.Help) {
|
|
444
|
+
const turnOnMessage = (isMacintosh
|
|
445
|
+
? AccessibilityHelpNLS.changeConfigToOnMac
|
|
446
|
+
: AccessibilityHelpNLS.changeConfigToOnWinLinux);
|
|
447
|
+
if (accessibilitySupport && provider instanceof AdvancedContentProvider && provider.verbositySettingKey === AccessibilityVerbositySettingId.Editor) {
|
|
448
|
+
message = AccessibilityHelpNLS.auto_on;
|
|
449
|
+
message += '\n';
|
|
450
|
+
}
|
|
451
|
+
else if (!accessibilitySupport) {
|
|
452
|
+
message = AccessibilityHelpNLS.auto_off + '\n' + turnOnMessage;
|
|
453
|
+
message += '\n';
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
const exitThisDialogHint = verbose && !provider.options.position ? ( localizeWithPath(_moduleId, 6, '\n\nExit this dialog (Escape).')) : '';
|
|
457
|
+
let content = provider.provideContent();
|
|
458
|
+
if (provider.options.type === AccessibleViewType.Help) {
|
|
459
|
+
const resolvedContent = resolveContentAndKeybindingItems(this._keybindingService, content + readMoreLink + disableHelpHint + exitThisDialogHint);
|
|
460
|
+
if (resolvedContent) {
|
|
461
|
+
content = resolvedContent.content.value;
|
|
462
|
+
if (resolvedContent.configureKeybindingItems) {
|
|
463
|
+
provider.options.configureKeybindingItems = resolvedContent.configureKeybindingItems;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
const newContent = message + content;
|
|
468
|
+
this.calculateCodeBlocks(newContent);
|
|
469
|
+
this._currentContent = newContent;
|
|
470
|
+
this._updateContextKeys(provider, true);
|
|
471
|
+
const widgetIsFocused = this._editorWidget.hasTextFocus() || this._editorWidget.hasWidgetFocus();
|
|
472
|
+
this._getTextModel(( (URI.from(
|
|
473
|
+
{ path: `accessible-view-${provider.id}`, scheme: 'accessible-view', fragment: this._currentContent }
|
|
474
|
+
)))).then((model) => {
|
|
475
|
+
if (!model) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
this._editorWidget.setModel(model);
|
|
479
|
+
const domNode = this._editorWidget.getDomNode();
|
|
480
|
+
if (!domNode) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
model.setLanguage(provider.options.language ?? 'markdown');
|
|
484
|
+
container.appendChild(this._container);
|
|
485
|
+
let actionsHint = '';
|
|
486
|
+
const hasActions = this._accessibleViewSupportsNavigation.get() || this._accessibleViewVerbosityEnabled.get() || this._accessibleViewGoToSymbolSupported.get() || provider.actions?.length;
|
|
487
|
+
if (verbose && !showAccessibleViewHelp && hasActions) {
|
|
488
|
+
actionsHint = provider.options.position ? ( localizeWithPath(
|
|
489
|
+
_moduleId,
|
|
490
|
+
7,
|
|
491
|
+
'Explore actions such as disabling this hint (Shift+Tab), use Escape to exit this dialog.'
|
|
492
|
+
)) : ( localizeWithPath(_moduleId, 8, 'Explore actions such as disabling this hint (Shift+Tab).'));
|
|
493
|
+
}
|
|
494
|
+
let ariaLabel = provider.options.type === AccessibleViewType.Help ? ( localizeWithPath(_moduleId, 9, "Accessibility Help")) : ( localizeWithPath(_moduleId, 10, "Accessible View"));
|
|
495
|
+
this._title.textContent = ariaLabel;
|
|
496
|
+
if (actionsHint && provider.options.type === AccessibleViewType.View) {
|
|
497
|
+
ariaLabel = ( localizeWithPath(_moduleId, 11, "Accessible View, {0}", actionsHint));
|
|
498
|
+
}
|
|
499
|
+
else if (actionsHint) {
|
|
500
|
+
ariaLabel = ( localizeWithPath(_moduleId, 12, "Accessibility Help, {0}", actionsHint));
|
|
501
|
+
}
|
|
502
|
+
if (isWindows && widgetIsFocused) {
|
|
503
|
+
ariaLabel = '';
|
|
504
|
+
}
|
|
505
|
+
this._editorWidget.updateOptions({ ariaLabel });
|
|
506
|
+
this._editorWidget.focus();
|
|
507
|
+
if (this._currentProvider?.options.position) {
|
|
508
|
+
const position = this._editorWidget.getPosition();
|
|
509
|
+
const isDefaultPosition = position?.lineNumber === 1 && position.column === 1;
|
|
510
|
+
if (this._currentProvider.options.position === 'bottom' || this._currentProvider.options.position === 'initial-bottom' && isDefaultPosition) {
|
|
511
|
+
const lastLine = this.editorWidget.getModel()?.getLineCount();
|
|
512
|
+
const position = lastLine !== undefined && lastLine > 0 ? ( (new Position(lastLine, 1))) : undefined;
|
|
513
|
+
if (position) {
|
|
514
|
+
this._editorWidget.setPosition(position);
|
|
515
|
+
this._editorWidget.revealLine(position.lineNumber);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
this._updateToolbar(this._currentProvider.actions, provider.options.type);
|
|
521
|
+
const hide = (e) => {
|
|
522
|
+
if (!this._inQuickPick) {
|
|
523
|
+
provider.onClose();
|
|
524
|
+
}
|
|
525
|
+
e?.stopPropagation();
|
|
526
|
+
this._contextViewService.hideContextView();
|
|
527
|
+
this._updateContextKeys(provider, false);
|
|
528
|
+
this._lastProvider = undefined;
|
|
529
|
+
this._currentContent = undefined;
|
|
530
|
+
};
|
|
531
|
+
const disposableStore = ( (new DisposableStore()));
|
|
532
|
+
disposableStore.add(this._editorWidget.onKeyDown((e) => {
|
|
533
|
+
if (e.keyCode === KeyCode.Enter) {
|
|
534
|
+
this._commandService.executeCommand('editor.action.openLink');
|
|
535
|
+
}
|
|
536
|
+
else if (e.keyCode === KeyCode.Escape || shouldHide(e.browserEvent, this._keybindingService, this._configurationService)) {
|
|
537
|
+
hide(e);
|
|
538
|
+
}
|
|
539
|
+
else if (e.keyCode === KeyCode.KeyH && provider.options.readMoreUrl) {
|
|
540
|
+
const url = provider.options.readMoreUrl;
|
|
541
|
+
alert(AccessibilityHelpNLS.openingDocs);
|
|
542
|
+
this._openerService.open(( (URI.parse(url))));
|
|
543
|
+
e.preventDefault();
|
|
544
|
+
e.stopPropagation();
|
|
545
|
+
}
|
|
546
|
+
if (provider instanceof AdvancedContentProvider) {
|
|
547
|
+
provider.onKeyDown?.(e);
|
|
548
|
+
}
|
|
549
|
+
}));
|
|
550
|
+
disposableStore.add(addDisposableListener(this._toolbar.getElement(), EventType.KEY_DOWN, (e) => {
|
|
551
|
+
const keyboardEvent = ( (new StandardKeyboardEvent(e)));
|
|
552
|
+
if (keyboardEvent.equals(KeyCode.Escape)) {
|
|
553
|
+
hide(e);
|
|
554
|
+
}
|
|
555
|
+
}));
|
|
556
|
+
disposableStore.add(this._editorWidget.onDidBlurEditorWidget(() => {
|
|
557
|
+
if (!isActiveElement(this._toolbar.getElement())) {
|
|
558
|
+
hide();
|
|
559
|
+
}
|
|
560
|
+
}));
|
|
561
|
+
disposableStore.add(this._editorWidget.onDidContentSizeChange(() => this._layout()));
|
|
562
|
+
disposableStore.add(this._layoutService.onDidLayoutActiveContainer(() => this._layout()));
|
|
563
|
+
return disposableStore;
|
|
564
|
+
}
|
|
565
|
+
_updateToolbar(providedActions, type) {
|
|
566
|
+
this._toolbar.setAriaLabel(type === AccessibleViewType.Help ? ( localizeWithPath(_moduleId, 13, 'Accessibility Help')) : ( localizeWithPath(_moduleId, 14, "Accessible View")));
|
|
567
|
+
const menuActions = [];
|
|
568
|
+
const toolbarMenu = this._register(this._menuService.createMenu(MenuId.AccessibleView, this._contextKeyService));
|
|
569
|
+
createAndFillInActionBarActions(toolbarMenu, {}, menuActions);
|
|
570
|
+
if (providedActions) {
|
|
571
|
+
for (const providedAction of providedActions) {
|
|
572
|
+
providedAction.class = providedAction.class || ThemeIcon.asClassName(Codicon.primitiveSquare);
|
|
573
|
+
providedAction.checked = undefined;
|
|
574
|
+
}
|
|
575
|
+
this._toolbar.setActions([...providedActions, ...menuActions]);
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
this._toolbar.setActions(menuActions);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
_layout() {
|
|
582
|
+
const dimension = this._layoutService.activeContainerDimension;
|
|
583
|
+
const maxHeight = dimension.height && dimension.height * .4;
|
|
584
|
+
const height = Math.min(maxHeight, this._editorWidget.getContentHeight());
|
|
585
|
+
const width = Math.min(dimension.width * 0.62 , DIMENSIONS.MAX_WIDTH);
|
|
586
|
+
this._editorWidget.layout({ width, height });
|
|
587
|
+
}
|
|
588
|
+
async _getTextModel(resource) {
|
|
589
|
+
const existing = this._modelService.getModel(resource);
|
|
590
|
+
if (existing && !existing.isDisposed()) {
|
|
591
|
+
return existing;
|
|
592
|
+
}
|
|
593
|
+
return this._modelService.createModel(resource.fragment, null, resource, false);
|
|
594
|
+
}
|
|
595
|
+
_goToSymbolsSupported() {
|
|
596
|
+
if (!this._currentProvider) {
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
return this._currentProvider.options.type === AccessibleViewType.Help || this._currentProvider.options.language === 'markdown' || this._currentProvider.options.language === undefined || (this._currentProvider instanceof AdvancedContentProvider && !!this._currentProvider.getSymbols?.());
|
|
600
|
+
}
|
|
601
|
+
_updateLastProvider() {
|
|
602
|
+
const provider = this._currentProvider;
|
|
603
|
+
if (!provider) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
const lastProvider = provider instanceof AdvancedContentProvider ? ( (new AdvancedContentProvider(
|
|
607
|
+
provider.id,
|
|
608
|
+
provider.options,
|
|
609
|
+
provider.provideContent.bind(provider),
|
|
610
|
+
provider.onClose.bind(provider),
|
|
611
|
+
provider.verbositySettingKey,
|
|
612
|
+
provider.onOpen?.bind(provider),
|
|
613
|
+
provider.actions,
|
|
614
|
+
provider.next?.bind(provider),
|
|
615
|
+
provider.previous?.bind(provider),
|
|
616
|
+
provider.onDidChangeContent?.bind(provider),
|
|
617
|
+
provider.onKeyDown?.bind(provider),
|
|
618
|
+
provider.getSymbols?.bind(provider)
|
|
619
|
+
))) : ( (new ExtensionContentProvider(
|
|
620
|
+
provider.id,
|
|
621
|
+
provider.options,
|
|
622
|
+
provider.provideContent.bind(provider),
|
|
623
|
+
provider.onClose.bind(provider),
|
|
624
|
+
provider.onOpen?.bind(provider),
|
|
625
|
+
provider.next?.bind(provider),
|
|
626
|
+
provider.previous?.bind(provider),
|
|
627
|
+
provider.actions,
|
|
628
|
+
provider.onDidChangeContent?.bind(provider)
|
|
629
|
+
)));
|
|
630
|
+
return lastProvider;
|
|
631
|
+
}
|
|
632
|
+
showAccessibleViewHelp() {
|
|
633
|
+
const lastProvider = this._updateLastProvider();
|
|
634
|
+
if (!lastProvider) {
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
const accessibleViewHelpProvider = {
|
|
638
|
+
id: lastProvider.id,
|
|
639
|
+
provideContent: () => lastProvider.options.customHelp ? lastProvider?.options.customHelp() : this._getAccessibleViewHelpDialogContent(this._goToSymbolsSupported()),
|
|
640
|
+
onClose: () => {
|
|
641
|
+
this._contextViewService.hideContextView();
|
|
642
|
+
queueMicrotask(() => this.show(lastProvider));
|
|
643
|
+
},
|
|
644
|
+
options: { type: AccessibleViewType.Help },
|
|
645
|
+
verbositySettingKey: lastProvider instanceof AdvancedContentProvider ? lastProvider.verbositySettingKey : undefined
|
|
646
|
+
};
|
|
647
|
+
this._contextViewService.hideContextView();
|
|
648
|
+
queueMicrotask(() => this.show(accessibleViewHelpProvider, undefined, true));
|
|
649
|
+
}
|
|
650
|
+
_getAccessibleViewHelpDialogContent(providerHasSymbols) {
|
|
651
|
+
const navigationHint = this._getNavigationHint();
|
|
652
|
+
const goToSymbolHint = this._getGoToSymbolHint(providerHasSymbols);
|
|
653
|
+
const toolbarHint = ( localizeWithPath(_moduleId, 15, "Navigate to the toolbar (Shift+Tab)."));
|
|
654
|
+
const chatHints = this._getChatHints();
|
|
655
|
+
let hint = ( localizeWithPath(_moduleId, 16, "In the accessible view, you can:\n"));
|
|
656
|
+
if (navigationHint) {
|
|
657
|
+
hint += ' - ' + navigationHint + '\n';
|
|
658
|
+
}
|
|
659
|
+
if (goToSymbolHint) {
|
|
660
|
+
hint += ' - ' + goToSymbolHint + '\n';
|
|
661
|
+
}
|
|
662
|
+
if (toolbarHint) {
|
|
663
|
+
hint += ' - ' + toolbarHint + '\n';
|
|
664
|
+
}
|
|
665
|
+
if (chatHints) {
|
|
666
|
+
hint += chatHints;
|
|
667
|
+
}
|
|
668
|
+
return hint;
|
|
669
|
+
}
|
|
670
|
+
_getChatHints() {
|
|
671
|
+
if (this._currentProvider?.id !== AccessibleViewProviderId.Chat) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
return [( localizeWithPath(
|
|
675
|
+
_moduleId,
|
|
676
|
+
17,
|
|
677
|
+
" - Insert the code block at the cursor<keybinding:workbench.action.chat.insertCodeBlock>."
|
|
678
|
+
)),
|
|
679
|
+
( localizeWithPath(
|
|
680
|
+
_moduleId,
|
|
681
|
+
18,
|
|
682
|
+
" - Insert the code block into a new file<keybinding:workbench.action.chat.insertIntoNewFile>."
|
|
683
|
+
)),
|
|
684
|
+
( localizeWithPath(
|
|
685
|
+
_moduleId,
|
|
686
|
+
19,
|
|
687
|
+
" - Run the code block in the terminal<keybinding:'workbench.action.chat.runInTerminal>.\n"
|
|
688
|
+
))].join('\n');
|
|
689
|
+
}
|
|
690
|
+
_getNavigationHint() {
|
|
691
|
+
return ( localizeWithPath(
|
|
692
|
+
_moduleId,
|
|
693
|
+
20,
|
|
694
|
+
"Show the next item<keybinding:{0}> or previous item<keybinding:{1}>.",
|
|
695
|
+
AccessibilityCommandId.ShowNext,
|
|
696
|
+
AccessibilityCommandId.ShowPrevious
|
|
697
|
+
));
|
|
698
|
+
}
|
|
699
|
+
_getDisableVerbosityHint() {
|
|
700
|
+
return ( localizeWithPath(
|
|
701
|
+
_moduleId,
|
|
702
|
+
21,
|
|
703
|
+
"\n\nDisable accessibility verbosity for this feature<keybinding:{0}>.",
|
|
704
|
+
AccessibilityCommandId.DisableVerbosityHint
|
|
705
|
+
));
|
|
706
|
+
}
|
|
707
|
+
_getGoToSymbolHint(providerHasSymbols) {
|
|
708
|
+
if (!providerHasSymbols) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
return ( localizeWithPath(
|
|
712
|
+
_moduleId,
|
|
713
|
+
22,
|
|
714
|
+
'Go to a symbol<keybinding:{0}>.',
|
|
715
|
+
AccessibilityCommandId.GoToSymbol
|
|
716
|
+
));
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
AccessibleView = ( (__decorate([
|
|
720
|
+
( (__param(0, IOpenerService))),
|
|
721
|
+
( (__param(1, IInstantiationService))),
|
|
722
|
+
( (__param(2, IConfigurationService))),
|
|
723
|
+
( (__param(3, IModelService))),
|
|
724
|
+
( (__param(4, IContextViewService))),
|
|
725
|
+
( (__param(5, IContextKeyService))),
|
|
726
|
+
( (__param(6, IAccessibilityService))),
|
|
727
|
+
( (__param(7, IKeybindingService))),
|
|
728
|
+
( (__param(8, ILayoutService))),
|
|
729
|
+
( (__param(9, IMenuService))),
|
|
730
|
+
( (__param(10, ICommandService))),
|
|
731
|
+
( (__param(11, IChatCodeBlockContextProviderService))),
|
|
732
|
+
( (__param(12, IStorageService))),
|
|
733
|
+
( (__param(13, IQuickInputService)))
|
|
734
|
+
], AccessibleView)));
|
|
735
|
+
let AccessibleViewService = class AccessibleViewService extends Disposable {
|
|
736
|
+
constructor(_instantiationService, _configurationService, _keybindingService) {
|
|
737
|
+
super();
|
|
738
|
+
this._instantiationService = _instantiationService;
|
|
739
|
+
this._configurationService = _configurationService;
|
|
740
|
+
this._keybindingService = _keybindingService;
|
|
741
|
+
}
|
|
742
|
+
show(provider, position) {
|
|
743
|
+
if (!this._accessibleView) {
|
|
744
|
+
this._accessibleView = this._register(this._instantiationService.createInstance(AccessibleView));
|
|
745
|
+
}
|
|
746
|
+
this._accessibleView.show(provider, undefined, undefined, position);
|
|
747
|
+
}
|
|
748
|
+
configureKeybindings() {
|
|
749
|
+
this._accessibleView?.configureKeybindings();
|
|
750
|
+
}
|
|
751
|
+
openHelpLink() {
|
|
752
|
+
this._accessibleView?.openHelpLink();
|
|
753
|
+
}
|
|
754
|
+
showLastProvider(id) {
|
|
755
|
+
this._accessibleView?.showLastProvider(id);
|
|
756
|
+
}
|
|
757
|
+
next() {
|
|
758
|
+
this._accessibleView?.next();
|
|
759
|
+
}
|
|
760
|
+
previous() {
|
|
761
|
+
this._accessibleView?.previous();
|
|
762
|
+
}
|
|
763
|
+
goToSymbol() {
|
|
764
|
+
this._accessibleView?.goToSymbol();
|
|
765
|
+
}
|
|
766
|
+
getOpenAriaHint(verbositySettingKey) {
|
|
767
|
+
if (!this._configurationService.getValue(verbositySettingKey)) {
|
|
768
|
+
return null;
|
|
769
|
+
}
|
|
770
|
+
const keybinding = this._keybindingService.lookupKeybinding(AccessibilityCommandId.OpenAccessibleView)?.getAriaLabel();
|
|
771
|
+
let hint = null;
|
|
772
|
+
if (keybinding) {
|
|
773
|
+
hint = ( localizeWithPath(_moduleId, 23, "Inspect this in the accessible view with {0}", keybinding));
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
hint = ( localizeWithPath(
|
|
777
|
+
_moduleId,
|
|
778
|
+
24,
|
|
779
|
+
"Inspect this in the accessible view via the command Open Accessible View which is currently not triggerable via keybinding."
|
|
780
|
+
));
|
|
781
|
+
}
|
|
782
|
+
return hint;
|
|
783
|
+
}
|
|
784
|
+
disableHint() {
|
|
785
|
+
this._accessibleView?.disableHint();
|
|
786
|
+
}
|
|
787
|
+
showAccessibleViewHelp() {
|
|
788
|
+
this._accessibleView?.showAccessibleViewHelp();
|
|
789
|
+
}
|
|
790
|
+
getPosition(id) {
|
|
791
|
+
return this._accessibleView?.getPosition(id) ?? undefined;
|
|
792
|
+
}
|
|
793
|
+
getLastPosition() {
|
|
794
|
+
const lastLine = this._accessibleView?.editorWidget.getModel()?.getLineCount();
|
|
795
|
+
return lastLine !== undefined && lastLine > 0 ? ( (new Position(lastLine, 1))) : undefined;
|
|
796
|
+
}
|
|
797
|
+
setPosition(position, reveal) {
|
|
798
|
+
const editorWidget = this._accessibleView?.editorWidget;
|
|
799
|
+
editorWidget?.setPosition(position);
|
|
800
|
+
if (reveal) {
|
|
801
|
+
editorWidget?.revealLine(position.lineNumber);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
getCodeBlockContext() {
|
|
805
|
+
return this._accessibleView?.getCodeBlockContext();
|
|
806
|
+
}
|
|
807
|
+
navigateToCodeBlock(type) {
|
|
808
|
+
this._accessibleView?.navigateToCodeBlock(type);
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
AccessibleViewService = ( (__decorate([
|
|
812
|
+
( (__param(0, IInstantiationService))),
|
|
813
|
+
( (__param(1, IConfigurationService))),
|
|
814
|
+
( (__param(2, IKeybindingService)))
|
|
815
|
+
], AccessibleViewService)));
|
|
816
|
+
let AccessibleViewSymbolQuickPick = class AccessibleViewSymbolQuickPick {
|
|
817
|
+
constructor(_accessibleView, _quickInputService) {
|
|
818
|
+
this._accessibleView = _accessibleView;
|
|
819
|
+
this._quickInputService = _quickInputService;
|
|
820
|
+
}
|
|
821
|
+
show(provider) {
|
|
822
|
+
const quickPick = this._quickInputService.createQuickPick();
|
|
823
|
+
quickPick.placeholder = ( localizeWithPath(_moduleId, 25, "Type to search symbols"));
|
|
824
|
+
quickPick.title = ( localizeWithPath(_moduleId, 26, "Go to Symbol Accessible View"));
|
|
825
|
+
const symbols = this._accessibleView.getSymbols();
|
|
826
|
+
if (!symbols) {
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
for (const symbol of symbols) {
|
|
830
|
+
}
|
|
831
|
+
quickPick.canSelectMany = false;
|
|
832
|
+
quickPick.items = symbols;
|
|
833
|
+
quickPick.show();
|
|
834
|
+
quickPick.onDidAccept(() => {
|
|
835
|
+
this._accessibleView.showSymbol(provider, quickPick.selectedItems[0]);
|
|
836
|
+
quickPick.hide();
|
|
837
|
+
});
|
|
838
|
+
quickPick.onDidHide(() => {
|
|
839
|
+
if (quickPick.selectedItems.length === 0) {
|
|
840
|
+
this._accessibleView.show(provider);
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
AccessibleViewSymbolQuickPick = ( (__decorate([
|
|
846
|
+
( (__param(1, IQuickInputService)))
|
|
847
|
+
], AccessibleViewSymbolQuickPick)));
|
|
848
|
+
function shouldHide(event, keybindingService, configurationService) {
|
|
849
|
+
if (!configurationService.getValue(AccessibilityWorkbenchSettingId.AccessibleViewCloseOnKeyPress)) {
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
const standardKeyboardEvent = ( (new StandardKeyboardEvent(event)));
|
|
853
|
+
const resolveResult = keybindingService.softDispatch(standardKeyboardEvent, standardKeyboardEvent.target);
|
|
854
|
+
const isValidChord = resolveResult.kind === ResultKind.MoreChordsNeeded;
|
|
855
|
+
if (keybindingService.inChordMode || isValidChord) {
|
|
856
|
+
return false;
|
|
857
|
+
}
|
|
858
|
+
return shouldHandleKey(event) && !event.ctrlKey && !event.altKey && !event.metaKey && !event.shiftKey;
|
|
859
|
+
}
|
|
860
|
+
function shouldHandleKey(event) {
|
|
861
|
+
return !!event.code.match(/^(Key[A-Z]|Digit[0-9]|Equal|Comma|Period|Slash|Quote|Backquote|Backslash|Minus|Semicolon|Space|Enter)$/);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
export { AccessibleView, AccessibleViewService };
|