@cloud-ru/ds-code-editor 1.0.3-preview-fe0a44cc.0 → 1.0.3-preview-848e7fc1.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.
@@ -102,8 +102,6 @@ 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,
107
105
  'scrollbarSlider.background': withAlpha(themeValues.text.main, 0.16),
108
106
  'scrollbarSlider.hoverBackground': withAlpha(themeValues.text.main, 0.28),
109
107
  'scrollbarSlider.activeBackground': withAlpha(themeValues.text.main, 0.4),
@@ -125,7 +123,7 @@ function CodeEditorClient({ themeName, className, theme, options, loading, backg
125
123
  }), [themeValues]);
126
124
  const dark = (0, react_2.useMemo)(() => {
127
125
  const bg = themeValues?.bg;
128
- return bg ? !(0, utils_2.isLightBackground)(bg) : false;
126
+ return bg ? (0, utils_2.isDark)(bg) : false;
129
127
  }, [themeValues?.bg]);
130
128
  // defineTheme writes to monaco's global theme registry. Run via layoutEffect
131
129
  // so the theme is registered before <Editor theme=... /> mounts (avoid FOUC),
@@ -29,7 +29,6 @@ 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;
33
32
  'scrollbarSlider.background': string;
34
33
  'scrollbarSlider.hoverBackground': string;
35
34
  'scrollbarSlider.activeBackground': string;
@@ -28,7 +28,6 @@ exports.DEFAULT_THEME_VALUES = {
28
28
  'editor.lineHighlightBackground': '#decdfb',
29
29
  'editorCursor.foreground': '#794ed3',
30
30
  'editorWhitespace.foreground': '#dedede',
31
- 'editor.placeholder.foreground': '#898989',
32
31
  'scrollbarSlider.background': '#75757552',
33
32
  'scrollbarSlider.hoverBackground': '#7575757B',
34
33
  'scrollbarSlider.activeBackground': '#757575A4',
@@ -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 isLightBackground(color: string): boolean;
4
+ export declare function isDark(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.isLightBackground = isLightBackground;
5
+ exports.isDark = isDark;
6
6
  exports.hexWithAlpha = hexWithAlpha;
7
7
  exports.uppercaseFirstLetter = uppercaseFirstLetter;
8
8
  const constants_1 = require("./constants");
@@ -61,10 +61,9 @@ function rgb2hsl(htmlColor) {
61
61
  }
62
62
  return [h, s, l];
63
63
  }
64
- // Возвращает true, когда фон СВЕТЛЫЙ («достаточно светлый, чтобы текст на нём был тёмным»).
65
- // Пороги оттенка — по шкале 0–360. Прежнее имя isDark читалось ровно наоборот и уже привело
66
- // к тому, что на светлой теме редактор получал базовую тему vs-dark.
67
- function isLightBackground(color) {
64
+ // Treats colors with low hue + medium lightness OR high hue + high lightness as
65
+ // 'light enough that text should be dark'. Hue thresholds use the 0–360 scale.
66
+ function isDark(color) {
68
67
  const [h, , l] = rgb2hsl(color);
69
68
  return (h < 198 && l >= 0.5) || (h >= 198 && l >= 0.75);
70
69
  }
@@ -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, isLightBackground, uppercaseFirstLetter } from '../../utils.js';
11
+ import { hexWithAlpha, isDark, 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,8 +96,6 @@ 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,
101
99
  'scrollbarSlider.background': withAlpha(themeValues.text.main, 0.16),
102
100
  'scrollbarSlider.hoverBackground': withAlpha(themeValues.text.main, 0.28),
103
101
  'scrollbarSlider.activeBackground': withAlpha(themeValues.text.main, 0.4),
@@ -119,7 +117,7 @@ function CodeEditorClient({ themeName, className, theme, options, loading, backg
119
117
  }), [themeValues]);
120
118
  const dark = useMemo(() => {
121
119
  const bg = themeValues?.bg;
122
- return bg ? !isLightBackground(bg) : false;
120
+ return bg ? isDark(bg) : false;
123
121
  }, [themeValues?.bg]);
124
122
  // defineTheme writes to monaco's global theme registry. Run via layoutEffect
125
123
  // so the theme is registered before <Editor theme=... /> mounts (avoid FOUC),
@@ -29,7 +29,6 @@ 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;
33
32
  'scrollbarSlider.background': string;
34
33
  'scrollbarSlider.hoverBackground': string;
35
34
  'scrollbarSlider.activeBackground': string;
@@ -25,7 +25,6 @@ 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',
29
28
  'scrollbarSlider.background': '#75757552',
30
29
  'scrollbarSlider.hoverBackground': '#7575757B',
31
30
  'scrollbarSlider.activeBackground': '#757575A4',
@@ -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 isLightBackground(color: string): boolean;
4
+ export declare function isDark(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,10 +54,9 @@ export function rgb2hsl(htmlColor) {
54
54
  }
55
55
  return [h, s, l];
56
56
  }
57
- // Возвращает true, когда фон СВЕТЛЫЙ («достаточно светлый, чтобы текст на нём был тёмным»).
58
- // Пороги оттенка — по шкале 0–360. Прежнее имя isDark читалось ровно наоборот и уже привело
59
- // к тому, что на светлой теме редактор получал базовую тему vs-dark.
60
- export function isLightBackground(color) {
57
+ // Treats colors with low hue + medium lightness OR high hue + high lightness as
58
+ // 'light enough that text should be dark'. Hue thresholds use the 0–360 scale.
59
+ export function isDark(color) {
61
60
  const [h, , l] = rgb2hsl(color);
62
61
  return (h < 198 && l >= 0.5) || (h >= 198 && l >= 0.75);
63
62
  }