Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/browser/style.ts
5240 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
6
import './media/style.css';
7
import { registerThemingParticipant } from '../../platform/theme/common/themeService.js';
8
import { WORKBENCH_BACKGROUND, TITLE_BAR_ACTIVE_BACKGROUND } from '../common/theme.js';
9
import { isWeb, isIOS } from '../../base/common/platform.js';
10
import { createMetaElement } from '../../base/browser/dom.js';
11
import { isSafari, isStandalone } from '../../base/browser/browser.js';
12
import { selectionBackground } from '../../platform/theme/common/colorRegistry.js';
13
import { mainWindow } from '../../base/browser/window.js';
14
15
registerThemingParticipant((theme, collector) => {
16
17
// Background (helps for subpixel-antialiasing on Windows)
18
const workbenchBackground = WORKBENCH_BACKGROUND(theme);
19
collector.addRule(`.monaco-workbench { background-color: ${workbenchBackground}; }`);
20
21
// Selection (do NOT remove - https://github.com/microsoft/vscode/issues/169662)
22
const windowSelectionBackground = theme.getColor(selectionBackground);
23
if (windowSelectionBackground) {
24
collector.addRule(`.monaco-workbench ::selection { background-color: ${windowSelectionBackground}; }`);
25
}
26
27
// Update <meta name="theme-color" content=""> based on selected theme
28
if (isWeb) {
29
const titleBackground = theme.getColor(TITLE_BAR_ACTIVE_BACKGROUND);
30
if (titleBackground) {
31
const metaElementId = 'monaco-workbench-meta-theme-color';
32
// eslint-disable-next-line no-restricted-syntax
33
let metaElement = mainWindow.document.getElementById(metaElementId) as HTMLMetaElement | null;
34
if (!metaElement) {
35
metaElement = createMetaElement();
36
metaElement.name = 'theme-color';
37
metaElement.id = metaElementId;
38
}
39
40
metaElement.content = titleBackground.toString();
41
}
42
}
43
44
// We disable user select on the root element, however on Safari this seems
45
// to prevent any text selection in the monaco editor. As a workaround we
46
// allow to select text in monaco editor instances.
47
if (isSafari) {
48
collector.addRule(`
49
body.web {
50
touch-action: none;
51
}
52
.monaco-workbench .monaco-editor .view-lines {
53
user-select: text;
54
-webkit-user-select: text;
55
}
56
`);
57
}
58
59
// Update body background color to ensure the home indicator area looks similar to the workbench
60
if (isIOS && isStandalone()) {
61
collector.addRule(`body { background-color: ${workbenchBackground}; }`);
62
}
63
});
64
65