@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 {
|
|
22
|
-
|
|
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();
|
package/dist/components/utils.js
CHANGED
|
@@ -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
|
|
38
|
-
var _a;
|
|
37
|
+
export function initMonacoEditorReactLoaderConfig() {
|
|
39
38
|
if (!window) {
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
|
-
|
|
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-
|
|
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": "
|
|
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 {
|
|
11
|
+
import { initMonacoEditorReactLoaderConfig, isDark } from './utils';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
initMonacoEditorReactLoaderConfig();
|
|
14
14
|
|
|
15
15
|
export type CodeEditorProps = WithSupportProps<{
|
|
16
16
|
/** Класснейм подключенной темы (из хука useThemeConfig() или ThemeProvider)
|
package/src/components/utils.ts
CHANGED
|
@@ -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
|
|
51
|
+
export function initMonacoEditorReactLoaderConfig() {
|
|
52
52
|
if (!window) {
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
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 } });
|