awa
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
import { addDisposableListener } from '../../../base/browser/dom.js';
|
||||
import { mainWindow } from '../../../base/browser/window.js';
|
||||
import { Emitter } from '../../../base/common/event.js';
|
||||
import { Disposable } from '../../../base/common/lifecycle.js';
|
||||
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from '../common/accessibility.js';
|
||||
import { IConfigurationService } from '../../configuration/common/configuration.js';
|
||||
import { IContextKeyService } from '../../contextkey/common/contextkey.js';
|
||||
import { ILayoutService } from '../../layout/browser/layoutService.js';
|
||||
let AccessibilityService = class AccessibilityService extends Disposable {
|
||||
constructor(_contextKeyService, _layoutService, _configurationService) {
|
||||
super();
|
||||
this._contextKeyService = _contextKeyService;
|
||||
this._layoutService = _layoutService;
|
||||
this._configurationService = _configurationService;
|
||||
this._accessibilitySupport = 0 /* AccessibilitySupport.Unknown */;
|
||||
this._onDidChangeScreenReaderOptimized = new Emitter();
|
||||
this._onDidChangeReducedMotion = new Emitter();
|
||||
this._onDidChangeLinkUnderline = new Emitter();
|
||||
this._accessibilityModeEnabledContext = CONTEXT_ACCESSIBILITY_MODE_ENABLED.bindTo(this._contextKeyService);
|
||||
const updateContextKey = () => this._accessibilityModeEnabledContext.set(this.isScreenReaderOptimized());
|
||||
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('editor.accessibilitySupport')) {
|
||||
updateContextKey();
|
||||
this._onDidChangeScreenReaderOptimized.fire();
|
||||
}
|
||||
if (e.affectsConfiguration('workbench.reduceMotion')) {
|
||||
this._configMotionReduced = this._configurationService.getValue('workbench.reduceMotion');
|
||||
this._onDidChangeReducedMotion.fire();
|
||||
}
|
||||
}));
|
||||
updateContextKey();
|
||||
this._register(this.onDidChangeScreenReaderOptimized(() => updateContextKey()));
|
||||
const reduceMotionMatcher = mainWindow.matchMedia(`(prefers-reduced-motion: reduce)`);
|
||||
this._systemMotionReduced = reduceMotionMatcher.matches;
|
||||
this._configMotionReduced = this._configurationService.getValue('workbench.reduceMotion');
|
||||
this._linkUnderlinesEnabled = this._configurationService.getValue('accessibility.underlineLinks');
|
||||
this.initReducedMotionListeners(reduceMotionMatcher);
|
||||
this.initLinkUnderlineListeners();
|
||||
}
|
||||
initReducedMotionListeners(reduceMotionMatcher) {
|
||||
this._register(addDisposableListener(reduceMotionMatcher, 'change', () => {
|
||||
this._systemMotionReduced = reduceMotionMatcher.matches;
|
||||
if (this._configMotionReduced === 'auto') {
|
||||
this._onDidChangeReducedMotion.fire();
|
||||
}
|
||||
}));
|
||||
const updateRootClasses = () => {
|
||||
const reduce = this.isMotionReduced();
|
||||
this._layoutService.mainContainer.classList.toggle('reduce-motion', reduce);
|
||||
this._layoutService.mainContainer.classList.toggle('enable-motion', !reduce);
|
||||
};
|
||||
updateRootClasses();
|
||||
this._register(this.onDidChangeReducedMotion(() => updateRootClasses()));
|
||||
}
|
||||
initLinkUnderlineListeners() {
|
||||
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('accessibility.underlineLinks')) {
|
||||
const linkUnderlinesEnabled = this._configurationService.getValue('accessibility.underlineLinks');
|
||||
this._linkUnderlinesEnabled = linkUnderlinesEnabled;
|
||||
this._onDidChangeLinkUnderline.fire();
|
||||
}
|
||||
}));
|
||||
const updateLinkUnderlineClasses = () => {
|
||||
const underlineLinks = this._linkUnderlinesEnabled;
|
||||
this._layoutService.mainContainer.classList.toggle('underline-links', underlineLinks);
|
||||
};
|
||||
updateLinkUnderlineClasses();
|
||||
this._register(this.onDidChangeLinkUnderlines(() => updateLinkUnderlineClasses()));
|
||||
}
|
||||
onDidChangeLinkUnderlines(listener) {
|
||||
return this._onDidChangeLinkUnderline.event(listener);
|
||||
}
|
||||
get onDidChangeScreenReaderOptimized() {
|
||||
return this._onDidChangeScreenReaderOptimized.event;
|
||||
}
|
||||
isScreenReaderOptimized() {
|
||||
const config = this._configurationService.getValue('editor.accessibilitySupport');
|
||||
return config === 'on' || (config === 'auto' && this._accessibilitySupport === 2 /* AccessibilitySupport.Enabled */);
|
||||
}
|
||||
get onDidChangeReducedMotion() {
|
||||
return this._onDidChangeReducedMotion.event;
|
||||
}
|
||||
isMotionReduced() {
|
||||
const config = this._configMotionReduced;
|
||||
return config === 'on' || (config === 'auto' && this._systemMotionReduced);
|
||||
}
|
||||
getAccessibilitySupport() {
|
||||
return this._accessibilitySupport;
|
||||
}
|
||||
};
|
||||
AccessibilityService = __decorate([
|
||||
__param(0, IContextKeyService),
|
||||
__param(1, ILayoutService),
|
||||
__param(2, IConfigurationService)
|
||||
], AccessibilityService);
|
||||
export { AccessibilityService };
|
||||
//# sourceMappingURL=accessibilityService.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,24 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
export const AccessibleViewRegistry = new class AccessibleViewRegistry {
|
||||
constructor() {
|
||||
this._implementations = [];
|
||||
}
|
||||
register(implementation) {
|
||||
this._implementations.push(implementation);
|
||||
return {
|
||||
dispose: () => {
|
||||
const idx = this._implementations.indexOf(implementation);
|
||||
if (idx !== -1) {
|
||||
this._implementations.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
getImplementations() {
|
||||
return this._implementations;
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=accessibleViewRegistry.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/platform/accessibility/browser/accessibleViewRegistry.ts","vs/platform/accessibility/browser/accessibleViewRegistry.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAOhG,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,MAAM,sBAAsB;IAA5B;QACzC,qBAAgB,GAAoC,EAAE,CAAC;IAiBxD,CAAC;IAfA,QAAQ,CAAC,cAA6C;QACrD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC3C,OAAO;YACN,OAAO,EAAE,GAAG,EAAE;gBACb,MAAM,GAAG,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBAC1D,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;oBAChB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBACtC,CAAC;YACF,CAAC;SACD,CAAC;IACH,CAAC;IAED,kBAAkB;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC9B,CAAC;CACD,CAAC","file":"accessibleViewRegistry.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IDisposable } from '../../../base/common/lifecycle.js';\n\nexport interface IAccessibleViewImplementation {\n}\n\nexport const AccessibleViewRegistry = new class AccessibleViewRegistry {\n\t_implementations: IAccessibleViewImplementation[] = [];\n\n\tregister(implementation: IAccessibleViewImplementation): IDisposable {\n\t\tthis._implementations.push(implementation);\n\t\treturn {\n\t\t\tdispose: () => {\n\t\t\t\tconst idx = this._implementations.indexOf(implementation);\n\t\t\t\tif (idx !== -1) {\n\t\t\t\t\tthis._implementations.splice(idx, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tgetImplementations(): IAccessibleViewImplementation[] {\n\t\treturn this._implementations;\n\t}\n};\n\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IDisposable } from '../../../base/common/lifecycle.js';\n\nexport interface IAccessibleViewImplementation {\n}\n\nexport const AccessibleViewRegistry = new class AccessibleViewRegistry {\n\t_implementations: IAccessibleViewImplementation[] = [];\n\n\tregister(implementation: IAccessibleViewImplementation): IDisposable {\n\t\tthis._implementations.push(implementation);\n\t\treturn {\n\t\t\tdispose: () => {\n\t\t\t\tconst idx = this._implementations.indexOf(implementation);\n\t\t\t\tif (idx !== -1) {\n\t\t\t\t\tthis._implementations.splice(idx, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tgetImplementations(): IAccessibleViewImplementation[] {\n\t\treturn this._implementations;\n\t}\n};\n\n"]}
|
||||
@@ -0,0 +1,9 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { RawContextKey } from '../../contextkey/common/contextkey.js';
|
||||
import { createDecorator } from '../../instantiation/common/instantiation.js';
|
||||
export const IAccessibilityService = createDecorator('accessibilityService');
|
||||
export const CONTEXT_ACCESSIBILITY_MODE_ENABLED = new RawContextKey('accessibilityModeEnabled', false);
|
||||
//# sourceMappingURL=accessibility.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/platform/accessibility/common/accessibility.ts","vs/platform/accessibility/common/accessibility.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAE9E,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAwB,sBAAsB,CAAC,CAAC;AAsBpG,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,aAAa,CAAU,0BAA0B,EAAE,KAAK,CAAC,CAAC","file":"accessibility.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Event } from '../../../base/common/event.js';\nimport { RawContextKey } from '../../contextkey/common/contextkey.js';\nimport { createDecorator } from '../../instantiation/common/instantiation.js';\n\nexport const IAccessibilityService = createDecorator<IAccessibilityService>('accessibilityService');\n\nexport interface IAccessibilityService {\n\treadonly _serviceBrand: undefined;\n\n\treadonly onDidChangeScreenReaderOptimized: Event<void>;\n\tisScreenReaderOptimized(): boolean;\n\tisMotionReduced(): boolean;\n\tgetAccessibilitySupport(): AccessibilitySupport;\n}\n\nexport const enum AccessibilitySupport {\n\t/**\n\t * This should be the browser case where it is not known if a screen reader is attached or no.\n\t */\n\tUnknown = 0,\n\n\tDisabled = 1,\n\n\tEnabled = 2\n}\n\nexport const CONTEXT_ACCESSIBILITY_MODE_ENABLED = new RawContextKey<boolean>('accessibilityModeEnabled', false);\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Event } from '../../../base/common/event.js';\nimport { RawContextKey } from '../../contextkey/common/contextkey.js';\nimport { createDecorator } from '../../instantiation/common/instantiation.js';\n\nexport const IAccessibilityService = createDecorator<IAccessibilityService>('accessibilityService');\n\nexport interface IAccessibilityService {\n\treadonly _serviceBrand: undefined;\n\n\treadonly onDidChangeScreenReaderOptimized: Event<void>;\n\tisScreenReaderOptimized(): boolean;\n\tisMotionReduced(): boolean;\n\tgetAccessibilitySupport(): AccessibilitySupport;\n}\n\nexport const enum AccessibilitySupport {\n\t/**\n\t * This should be the browser case where it is not known if a screen reader is attached or no.\n\t */\n\tUnknown = 0,\n\n\tDisabled = 1,\n\n\tEnabled = 2\n}\n\nexport const CONTEXT_ACCESSIBILITY_MODE_ENABLED = new RawContextKey<boolean>('accessibilityModeEnabled', false);\n"]}
|
||||
Reference in New Issue
Block a user