-
Notifications
You must be signed in to change notification settings - Fork 28.9k
/
style.ts
62 lines (54 loc) · 2.53 KB
/
style.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/style';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { WORKBENCH_BACKGROUND, TITLE_BAR_ACTIVE_BACKGROUND } from 'vs/workbench/common/theme';
import { isWeb, isIOS } from 'vs/base/common/platform';
import { createMetaElement } from 'vs/base/browser/dom';
import { isSafari, isStandalone } from 'vs/base/browser/browser';
import { selectionBackground } from 'vs/platform/theme/common/colorRegistry';
import { mainWindow } from 'vs/base/browser/window';
registerThemingParticipant((theme, collector) => {
// Background (helps for subpixel-antialiasing on Windows)
const workbenchBackground = WORKBENCH_BACKGROUND(theme);
collector.addRule(`.monaco-workbench { background-color: ${workbenchBackground}; }`);
// Selection (do NOT remove - https://github.com/microsoft/vscode/issues/169662)
const windowSelectionBackground = theme.getColor(selectionBackground);
if (windowSelectionBackground) {
collector.addRule(`.monaco-workbench ::selection { background-color: ${windowSelectionBackground}; }`);
}
// Update <meta name="theme-color" content=""> based on selected theme
if (isWeb) {
const titleBackground = theme.getColor(TITLE_BAR_ACTIVE_BACKGROUND);
if (titleBackground) {
const metaElementId = 'monaco-workbench-meta-theme-color';
let metaElement = mainWindow.document.getElementById(metaElementId) as HTMLMetaElement | null;
if (!metaElement) {
metaElement = createMetaElement();
metaElement.name = 'theme-color';
metaElement.id = metaElementId;
}
metaElement.content = titleBackground.toString();
}
}
// We disable user select on the root element, however on Safari this seems
// to prevent any text selection in the monaco editor. As a workaround we
// allow to select text in monaco editor instances.
if (isSafari) {
collector.addRule(`
body.web {
touch-action: none;
}
.monaco-workbench .monaco-editor .view-lines {
user-select: text;
-webkit-user-select: text;
}
`);
}
// Update body background color to ensure the home indicator area looks similar to the workbench
if (isIOS && isStandalone()) {
collector.addRule(`body { background-color: ${workbenchBackground}; }`);
}
});