in patched-vscode/src/vs/workbench/contrib/accessibility/browser/accessibleView.ts [487:614]
private _render(provider: AccesibleViewContentProvider, container: HTMLElement, showAccessibleViewHelp?: boolean): IDisposable {
this._currentProvider = provider;
this._accessibleViewCurrentProviderId.set(provider.id);
const verbose = this._verbosityEnabled();
const readMoreLink = provider.options.readMoreUrl ? localize("openDoc", "\n\nOpen a browser window with more information related to accessibility<keybinding:{0}>.", AccessibilityCommandId.AccessibilityHelpOpenHelpLink) : '';
let disableHelpHint = '';
if (provider instanceof AdvancedContentProvider && provider.options.type === AccessibleViewType.Help && verbose) {
disableHelpHint = this._getDisableVerbosityHint();
}
const accessibilitySupport = this._accessibilityService.isScreenReaderOptimized();
let message = '';
if (provider.options.type === AccessibleViewType.Help) {
const turnOnMessage = (
isMacintosh
? AccessibilityHelpNLS.changeConfigToOnMac
: AccessibilityHelpNLS.changeConfigToOnWinLinux
);
if (accessibilitySupport && provider instanceof AdvancedContentProvider && provider.verbositySettingKey === AccessibilityVerbositySettingId.Editor) {
message = AccessibilityHelpNLS.auto_on;
message += '\n';
} else if (!accessibilitySupport) {
message = AccessibilityHelpNLS.auto_off + '\n' + turnOnMessage;
message += '\n';
}
}
const exitThisDialogHint = verbose && !provider.options.position ? localize('exit', '\n\nExit this dialog (Escape).') : '';
let content = provider.provideContent();
if (provider.options.type === AccessibleViewType.Help) {
const resolvedContent = resolveContentAndKeybindingItems(this._keybindingService, content + readMoreLink + disableHelpHint + exitThisDialogHint);
if (resolvedContent) {
content = resolvedContent.content.value;
if (resolvedContent.configureKeybindingItems) {
provider.options.configureKeybindingItems = resolvedContent.configureKeybindingItems;
}
}
}
const newContent = message + content;
this.calculateCodeBlocks(newContent);
this._currentContent = newContent;
this._updateContextKeys(provider, true);
const widgetIsFocused = this._editorWidget.hasTextFocus() || this._editorWidget.hasWidgetFocus();
this._getTextModel(URI.from({ path: `accessible-view-${provider.id}`, scheme: 'accessible-view', fragment: this._currentContent })).then((model) => {
if (!model) {
return;
}
this._editorWidget.setModel(model);
const domNode = this._editorWidget.getDomNode();
if (!domNode) {
return;
}
model.setLanguage(provider.options.language ?? 'markdown');
container.appendChild(this._container);
let actionsHint = '';
const hasActions = this._accessibleViewSupportsNavigation.get() || this._accessibleViewVerbosityEnabled.get() || this._accessibleViewGoToSymbolSupported.get() || provider.actions?.length;
if (verbose && !showAccessibleViewHelp && hasActions) {
actionsHint = provider.options.position ? localize('ariaAccessibleViewActionsBottom', 'Explore actions such as disabling this hint (Shift+Tab), use Escape to exit this dialog.') : localize('ariaAccessibleViewActions', 'Explore actions such as disabling this hint (Shift+Tab).');
}
let ariaLabel = provider.options.type === AccessibleViewType.Help ? localize('accessibility-help', "Accessibility Help") : localize('accessible-view', "Accessible View");
this._title.textContent = ariaLabel;
if (actionsHint && provider.options.type === AccessibleViewType.View) {
ariaLabel = localize('accessible-view-hint', "Accessible View, {0}", actionsHint);
} else if (actionsHint) {
ariaLabel = localize('accessibility-help-hint', "Accessibility Help, {0}", actionsHint);
}
if (isWindows && widgetIsFocused) {
// prevent the screen reader on windows from reading
// the aria label again when it's refocused
ariaLabel = '';
}
this._editorWidget.updateOptions({ ariaLabel });
this._editorWidget.focus();
if (this._currentProvider?.options.position) {
const position = this._editorWidget.getPosition();
const isDefaultPosition = position?.lineNumber === 1 && position.column === 1;
if (this._currentProvider.options.position === 'bottom' || this._currentProvider.options.position === 'initial-bottom' && isDefaultPosition) {
const lastLine = this.editorWidget.getModel()?.getLineCount();
const position = lastLine !== undefined && lastLine > 0 ? new Position(lastLine, 1) : undefined;
if (position) {
this._editorWidget.setPosition(position);
this._editorWidget.revealLine(position.lineNumber);
}
}
}
});
this._updateToolbar(this._currentProvider.actions, provider.options.type);
const hide = (e?: KeyboardEvent | IKeyboardEvent): void => {
if (!this._inQuickPick) {
provider.onClose();
}
e?.stopPropagation();
this._contextViewService.hideContextView();
this._updateContextKeys(provider, false);
this._lastProvider = undefined;
this._currentContent = undefined;
};
const disposableStore = new DisposableStore();
disposableStore.add(this._editorWidget.onKeyDown((e) => {
if (e.keyCode === KeyCode.Enter) {
this._commandService.executeCommand('editor.action.openLink');
} else if (e.keyCode === KeyCode.Escape || shouldHide(e.browserEvent, this._keybindingService, this._configurationService)) {
hide(e);
} else if (e.keyCode === KeyCode.KeyH && provider.options.readMoreUrl) {
const url: string = provider.options.readMoreUrl;
alert(AccessibilityHelpNLS.openingDocs);
this._openerService.open(URI.parse(url));
e.preventDefault();
e.stopPropagation();
}
if (provider instanceof AdvancedContentProvider) {
provider.onKeyDown?.(e);
}
}));
disposableStore.add(addDisposableListener(this._toolbar.getElement(), EventType.KEY_DOWN, (e: KeyboardEvent) => {
const keyboardEvent = new StandardKeyboardEvent(e);
if (keyboardEvent.equals(KeyCode.Escape)) {
hide(e);
}
}));
disposableStore.add(this._editorWidget.onDidBlurEditorWidget(() => {
if (!isActiveElement(this._toolbar.getElement())) {
hide();
}
}));
disposableStore.add(this._editorWidget.onDidContentSizeChange(() => this._layout()));
disposableStore.add(this._layoutService.onDidLayoutActiveContainer(() => this._layout()));
return disposableStore;
}