@snack-uikit/code-editor 0.2.1-preview-01f9b65f.0 → 0.2.1-preview-a9faaab6.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.
@@ -18,8 +18,8 @@ import { extractSupportProps } from '@snack-uikit/utils';
18
18
  import { CODE_EDITOR_OPTIONS, DEFAULT_THEME_OPTIONS, DEFAULT_THEME_VALUES } from './constants';
19
19
  import { useCalculatedThemeValues } from './hooks';
20
20
  import styles from './styles.module.css';
21
- import { initMonacoEnvironment, isDark } from './utils';
22
- initMonacoEnvironment();
21
+ import { initMonacoEditorReactLoaderConfig, isDark } from './utils';
22
+ initMonacoEditorReactLoaderConfig();
23
23
  export function CodeEditor(_a) {
24
24
  var { themeClassName, className, theme, options, loading, hasBackground = true } = _a, props = __rest(_a, ["themeClassName", "className", "theme", "options", "loading", "hasBackground"]);
25
25
  const monaco = useMonaco();
@@ -1,3 +1,3 @@
1
1
  export declare function rgb2hsl(HTMLcolor: string): number[];
2
2
  export declare function isDark(color: string): boolean;
3
- export declare function initMonacoEnvironment(): void;
3
+ export declare function initMonacoEditorReactLoaderConfig(): void;
@@ -34,12 +34,13 @@ export function isDark(color) {
34
34
  const [h, _, l] = rgb2hsl(color);
35
35
  return (h < 0.55 && l >= 0.5) || (h >= 0.55 && l >= 0.75);
36
36
  }
37
- export function initMonacoEnvironment() {
38
- var _a;
37
+ export function initMonacoEditorReactLoaderConfig() {
39
38
  if (!window) {
40
39
  return;
41
40
  }
42
- const vs = (_a = window.MonacoEnvironment) === null || _a === void 0 ? void 0 : _a.baseUrl;
41
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
+ // @ts-ignore
43
+ const vs = window['__snack_code_editor_paths__'];
43
44
  if (vs) {
44
45
  loader.config({ paths: { vs } });
45
46
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.2.1-preview-01f9b65f.0",
7
+ "version": "0.2.1-preview-a9faaab6.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -37,5 +37,5 @@
37
37
  "@snack-uikit/utils": "3.3.0",
38
38
  "classnames": "2.5.1"
39
39
  },
40
- "gitHead": "4fc8efb2c8fab602fc1e0391b743448d6dffd89b"
40
+ "gitHead": "6314839f8b24a0700f000e7a40145e85f0b0eea2"
41
41
  }
@@ -8,9 +8,9 @@ import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
8
8
  import { CODE_EDITOR_OPTIONS, DEFAULT_THEME_OPTIONS, DEFAULT_THEME_VALUES } from './constants';
9
9
  import { useCalculatedThemeValues } from './hooks';
10
10
  import styles from './styles.module.scss';
11
- import { initMonacoEnvironment, isDark } from './utils';
11
+ import { initMonacoEditorReactLoaderConfig, isDark } from './utils';
12
12
 
13
- initMonacoEnvironment();
13
+ initMonacoEditorReactLoaderConfig();
14
14
 
15
15
  export type CodeEditorProps = WithSupportProps<{
16
16
  /** Класснейм подключенной темы (из хука useThemeConfig() или ThemeProvider)
@@ -48,12 +48,14 @@ export function isDark(color: string) {
48
48
  return (h < 0.55 && l >= 0.5) || (h >= 0.55 && l >= 0.75);
49
49
  }
50
50
 
51
- export function initMonacoEnvironment() {
51
+ export function initMonacoEditorReactLoaderConfig() {
52
52
  if (!window) {
53
53
  return;
54
54
  }
55
55
 
56
- const vs = window.MonacoEnvironment?.baseUrl;
56
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
57
+ // @ts-ignore
58
+ const vs = window['__snack_code_editor_paths__'] as string | undefined;
57
59
 
58
60
  if (vs) {
59
61
  loader.config({ paths: { vs } });