@cloud-ru/ds-code-editor 1.0.3-preview-848e7fc1.0 → 1.0.3-preview-6d260fa4.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/dist/cjs/components/CodeEditor/CodeEditor.js +3 -1
- package/dist/cjs/constants.d.ts +1 -0
- package/dist/cjs/constants.js +1 -0
- package/dist/cjs/utils.d.ts +1 -1
- package/dist/cjs/utils.js +5 -4
- package/dist/esm/components/CodeEditor/CodeEditor.js +4 -2
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/constants.js +1 -0
- package/dist/esm/utils.d.ts +1 -1
- package/dist/esm/utils.js +4 -3
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/CodeEditor/CodeEditor.tsx +4 -2
- package/src/constants.ts +1 -0
- package/src/utils.ts +4 -3
|
@@ -102,6 +102,8 @@ function CodeEditorClient({ themeName, className, theme, options, loading, backg
|
|
|
102
102
|
'editor.lineHighlightBorder': '#00000000',
|
|
103
103
|
'editorCursor.foreground': themeValues.brand.accent,
|
|
104
104
|
'editorWhitespace.foreground': themeValues.text.secondary,
|
|
105
|
+
// placeholder — наследовал светлый дефолт vs-dark и пропадал на светлом фоне.
|
|
106
|
+
'editor.placeholder.foreground': themeValues.text.secondary,
|
|
105
107
|
'scrollbarSlider.background': withAlpha(themeValues.text.main, 0.16),
|
|
106
108
|
'scrollbarSlider.hoverBackground': withAlpha(themeValues.text.main, 0.28),
|
|
107
109
|
'scrollbarSlider.activeBackground': withAlpha(themeValues.text.main, 0.4),
|
|
@@ -123,7 +125,7 @@ function CodeEditorClient({ themeName, className, theme, options, loading, backg
|
|
|
123
125
|
}), [themeValues]);
|
|
124
126
|
const dark = (0, react_2.useMemo)(() => {
|
|
125
127
|
const bg = themeValues?.bg;
|
|
126
|
-
return bg ? (0, utils_2.
|
|
128
|
+
return bg ? !(0, utils_2.isLightBackground)(bg) : false;
|
|
127
129
|
}, [themeValues?.bg]);
|
|
128
130
|
// defineTheme writes to monaco's global theme registry. Run via layoutEffect
|
|
129
131
|
// so the theme is registered before <Editor theme=... /> mounts (avoid FOUC),
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare const DEFAULT_THEME_VALUES: {
|
|
|
29
29
|
'editor.lineHighlightBackground': string;
|
|
30
30
|
'editorCursor.foreground': string;
|
|
31
31
|
'editorWhitespace.foreground': string;
|
|
32
|
+
'editor.placeholder.foreground': string;
|
|
32
33
|
'scrollbarSlider.background': string;
|
|
33
34
|
'scrollbarSlider.hoverBackground': string;
|
|
34
35
|
'scrollbarSlider.activeBackground': string;
|
package/dist/cjs/constants.js
CHANGED
|
@@ -28,6 +28,7 @@ exports.DEFAULT_THEME_VALUES = {
|
|
|
28
28
|
'editor.lineHighlightBackground': '#decdfb',
|
|
29
29
|
'editorCursor.foreground': '#794ed3',
|
|
30
30
|
'editorWhitespace.foreground': '#dedede',
|
|
31
|
+
'editor.placeholder.foreground': '#898989',
|
|
31
32
|
'scrollbarSlider.background': '#75757552',
|
|
32
33
|
'scrollbarSlider.hoverBackground': '#7575757B',
|
|
33
34
|
'scrollbarSlider.activeBackground': '#757575A4',
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SchemasSettings } from 'monaco-yaml';
|
|
2
2
|
import { JsonSchema } from './types';
|
|
3
3
|
export declare function rgb2hsl(htmlColor: string): [number, number, number];
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function isLightBackground(color: string): boolean;
|
|
5
5
|
/**
|
|
6
6
|
* Monaco theme parser ест только hex; rgba(...) превращает в fail-safe red.
|
|
7
7
|
* Возвращает `#RRGGBBAA` для допустимого цвета, пустую строку — иначе.
|
package/dist/cjs/utils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getJsonSchema = void 0;
|
|
4
4
|
exports.rgb2hsl = rgb2hsl;
|
|
5
|
-
exports.
|
|
5
|
+
exports.isLightBackground = isLightBackground;
|
|
6
6
|
exports.hexWithAlpha = hexWithAlpha;
|
|
7
7
|
exports.uppercaseFirstLetter = uppercaseFirstLetter;
|
|
8
8
|
const constants_1 = require("./constants");
|
|
@@ -61,9 +61,10 @@ function rgb2hsl(htmlColor) {
|
|
|
61
61
|
}
|
|
62
62
|
return [h, s, l];
|
|
63
63
|
}
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
|
|
64
|
+
// Возвращает true, когда фон СВЕТЛЫЙ («достаточно светлый, чтобы текст на нём был тёмным»).
|
|
65
|
+
// Пороги оттенка — по шкале 0–360. Прежнее имя isDark читалось ровно наоборот и уже привело
|
|
66
|
+
// к тому, что на светлой теме редактор получал базовую тему vs-dark.
|
|
67
|
+
function isLightBackground(color) {
|
|
67
68
|
const [h, , l] = rgb2hsl(color);
|
|
68
69
|
return (h < 198 && l >= 0.5) || (h >= 198 && l >= 0.75);
|
|
69
70
|
}
|
|
@@ -8,7 +8,7 @@ import { Editor, useMonaco } from '@monaco-editor/react';
|
|
|
8
8
|
import cn from 'classnames';
|
|
9
9
|
import { useCallback, useId, useMemo, useRef, useState } from 'react';
|
|
10
10
|
import { CODE_EDITOR_OPTIONS, DEFAULT_THEME_OPTIONS, DEFAULT_THEME_VALUES, TEST_IDS } from '../../constants.js';
|
|
11
|
-
import { hexWithAlpha,
|
|
11
|
+
import { hexWithAlpha, isLightBackground, uppercaseFirstLetter } from '../../utils.js';
|
|
12
12
|
import { useApplyJsonSchema, useCalculatedThemeValues } from './hooks.js';
|
|
13
13
|
import styles from './styles.module.css';
|
|
14
14
|
// monaco theme parser принимает только hex (#RRGGBB / #RRGGBBAA);
|
|
@@ -96,6 +96,8 @@ function CodeEditorClient({ themeName, className, theme, options, loading, backg
|
|
|
96
96
|
'editor.lineHighlightBorder': '#00000000',
|
|
97
97
|
'editorCursor.foreground': themeValues.brand.accent,
|
|
98
98
|
'editorWhitespace.foreground': themeValues.text.secondary,
|
|
99
|
+
// placeholder — наследовал светлый дефолт vs-dark и пропадал на светлом фоне.
|
|
100
|
+
'editor.placeholder.foreground': themeValues.text.secondary,
|
|
99
101
|
'scrollbarSlider.background': withAlpha(themeValues.text.main, 0.16),
|
|
100
102
|
'scrollbarSlider.hoverBackground': withAlpha(themeValues.text.main, 0.28),
|
|
101
103
|
'scrollbarSlider.activeBackground': withAlpha(themeValues.text.main, 0.4),
|
|
@@ -117,7 +119,7 @@ function CodeEditorClient({ themeName, className, theme, options, loading, backg
|
|
|
117
119
|
}), [themeValues]);
|
|
118
120
|
const dark = useMemo(() => {
|
|
119
121
|
const bg = themeValues?.bg;
|
|
120
|
-
return bg ?
|
|
122
|
+
return bg ? !isLightBackground(bg) : false;
|
|
121
123
|
}, [themeValues?.bg]);
|
|
122
124
|
// defineTheme writes to monaco's global theme registry. Run via layoutEffect
|
|
123
125
|
// so the theme is registered before <Editor theme=... /> mounts (avoid FOUC),
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare const DEFAULT_THEME_VALUES: {
|
|
|
29
29
|
'editor.lineHighlightBackground': string;
|
|
30
30
|
'editorCursor.foreground': string;
|
|
31
31
|
'editorWhitespace.foreground': string;
|
|
32
|
+
'editor.placeholder.foreground': string;
|
|
32
33
|
'scrollbarSlider.background': string;
|
|
33
34
|
'scrollbarSlider.hoverBackground': string;
|
|
34
35
|
'scrollbarSlider.activeBackground': string;
|
package/dist/esm/constants.js
CHANGED
|
@@ -25,6 +25,7 @@ export const DEFAULT_THEME_VALUES = {
|
|
|
25
25
|
'editor.lineHighlightBackground': '#decdfb',
|
|
26
26
|
'editorCursor.foreground': '#794ed3',
|
|
27
27
|
'editorWhitespace.foreground': '#dedede',
|
|
28
|
+
'editor.placeholder.foreground': '#898989',
|
|
28
29
|
'scrollbarSlider.background': '#75757552',
|
|
29
30
|
'scrollbarSlider.hoverBackground': '#7575757B',
|
|
30
31
|
'scrollbarSlider.activeBackground': '#757575A4',
|
package/dist/esm/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SchemasSettings } from 'monaco-yaml';
|
|
2
2
|
import { JsonSchema } from './types.js';
|
|
3
3
|
export declare function rgb2hsl(htmlColor: string): [number, number, number];
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function isLightBackground(color: string): boolean;
|
|
5
5
|
/**
|
|
6
6
|
* Monaco theme parser ест только hex; rgba(...) превращает в fail-safe red.
|
|
7
7
|
* Возвращает `#RRGGBBAA` для допустимого цвета, пустую строку — иначе.
|
package/dist/esm/utils.js
CHANGED
|
@@ -54,9 +54,10 @@ export function rgb2hsl(htmlColor) {
|
|
|
54
54
|
}
|
|
55
55
|
return [h, s, l];
|
|
56
56
|
}
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
|
|
57
|
+
// Возвращает true, когда фон СВЕТЛЫЙ («достаточно светлый, чтобы текст на нём был тёмным»).
|
|
58
|
+
// Пороги оттенка — по шкале 0–360. Прежнее имя isDark читалось ровно наоборот и уже привело
|
|
59
|
+
// к тому, что на светлой теме редактор получал базовую тему vs-dark.
|
|
60
|
+
export function isLightBackground(color) {
|
|
60
61
|
const [h, , l] = rgb2hsl(color);
|
|
61
62
|
return (h < 198 && l >= 0.5) || (h >= 198 && l >= 0.75);
|
|
62
63
|
}
|