@snack-uikit/code-editor 0.2.3-preview-94780dcd.0 → 0.2.4-preview-1f246c4a.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/CHANGELOG.md +11 -0
- package/dist/cjs/components/CodeEditor.js +123 -0
- package/dist/cjs/components/constants.js +116 -0
- package/dist/cjs/components/hooks.js +40 -0
- package/dist/cjs/components/index.js +25 -0
- package/dist/cjs/components/utils.js +52 -0
- package/dist/cjs/index.js +37 -0
- package/dist/esm/components/CodeEditor.d.ts +13 -0
- package/dist/esm/components/constants.d.ts +101 -0
- package/dist/esm/components/hooks.d.ts +44 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/utils.d.ts +3 -0
- package/dist/esm/index.js +6 -0
- package/package.json +9 -7
- package/dist/components/styles.module.css +0 -13
- /package/dist/{components → cjs/components}/CodeEditor.d.ts +0 -0
- /package/dist/{components → cjs/components}/constants.d.ts +0 -0
- /package/dist/{components → cjs/components}/hooks.d.ts +0 -0
- /package/dist/{components → cjs/components}/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/utils.d.ts +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{components → esm/components}/CodeEditor.js +0 -0
- /package/dist/{components → esm/components}/constants.js +0 -0
- /package/dist/{components → esm/components}/hooks.js +0 -0
- /package/dist/{components/index.js → esm/components/index.d.ts} +0 -0
- /package/dist/{components → esm/components}/utils.js +0 -0
- /package/dist/{index.js → esm/index.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.2.3 (2024-09-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **PDS-480:** remove direct usage of browser api elements ([1231ff7](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/1231ff7ab7a1b210b579a7b694633ef23bffcf44))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.2.2 (2024-07-19)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
12
|
+
return mod && mod.__esModule ? mod : {
|
|
13
|
+
"default": mod
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
19
|
+
exports.CodeEditor = CodeEditor;
|
|
20
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
21
|
+
const react_1 = require("@monaco-editor/react");
|
|
22
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
23
|
+
const react_2 = require("react");
|
|
24
|
+
const loaders_1 = require("@snack-uikit/loaders");
|
|
25
|
+
const utils_1 = require("@snack-uikit/utils");
|
|
26
|
+
const constants_1 = require("./constants");
|
|
27
|
+
const hooks_1 = require("./hooks");
|
|
28
|
+
const styles_module_scss_1 = __importDefault({});
|
|
29
|
+
const utils_2 = require("./utils");
|
|
30
|
+
(0, utils_2.initLoaderConfig)();
|
|
31
|
+
function CodeEditor(_a) {
|
|
32
|
+
var {
|
|
33
|
+
themeName,
|
|
34
|
+
className,
|
|
35
|
+
theme,
|
|
36
|
+
options,
|
|
37
|
+
loading,
|
|
38
|
+
hasBackground = true,
|
|
39
|
+
onMount
|
|
40
|
+
} = _a,
|
|
41
|
+
props = __rest(_a, ["themeName", "className", "theme", "options", "loading", "hasBackground", "onMount"]);
|
|
42
|
+
const monaco = (0, react_1.useMonaco)();
|
|
43
|
+
const [wrapperElement, setWrapperElement] = (0, react_2.useState)(null);
|
|
44
|
+
const onEditorMount = (0, react_2.useCallback)((editor, monaco) => {
|
|
45
|
+
var _a;
|
|
46
|
+
monaco && (0, utils_1.isBrowser)() && ((_a = document === null || document === void 0 ? void 0 : document.fonts) === null || _a === void 0 ? void 0 : _a.ready.finally(monaco.editor.remeasureFonts));
|
|
47
|
+
onMount === null || onMount === void 0 ? void 0 : onMount(editor, monaco);
|
|
48
|
+
}, [onMount]);
|
|
49
|
+
const themeValues = (0, hooks_1.useCalculatedThemeValues)({
|
|
50
|
+
themeName,
|
|
51
|
+
stylesOriginNode: wrapperElement
|
|
52
|
+
});
|
|
53
|
+
const themeDataWithoutBase = (0, react_2.useMemo)(() => Object.assign({
|
|
54
|
+
inherit: true
|
|
55
|
+
}, (themeValues === null || themeValues === void 0 ? void 0 : themeValues.sys) ? {
|
|
56
|
+
semanticTokenColors: {
|
|
57
|
+
enumMember: {
|
|
58
|
+
foreground: themeValues.sys.blue.textLight
|
|
59
|
+
},
|
|
60
|
+
'variable.constant': {
|
|
61
|
+
foreground: themeValues.sys.orange.textSupport
|
|
62
|
+
},
|
|
63
|
+
'variable.defaultLibrary': {
|
|
64
|
+
foreground: themeValues.sys.yellow.textSupport
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
rules: [{
|
|
68
|
+
foreground: themeValues.sys.neutral.textLight,
|
|
69
|
+
token: 'comment'
|
|
70
|
+
}, {
|
|
71
|
+
foreground: themeValues.sys.green.textSupport,
|
|
72
|
+
token: 'string'
|
|
73
|
+
}, {
|
|
74
|
+
foreground: themeValues.sys.yellow.textSupport,
|
|
75
|
+
token: 'constant'
|
|
76
|
+
}, {
|
|
77
|
+
foreground: themeValues.sys.blue.accentDefault,
|
|
78
|
+
token: 'keyword'
|
|
79
|
+
}],
|
|
80
|
+
colors: {
|
|
81
|
+
'editor.background': '#00000000',
|
|
82
|
+
'editor.foreground': themeValues.sys.neutral.textMain,
|
|
83
|
+
'editor.selectionBackground': themeValues.sys.primary.decorHovered,
|
|
84
|
+
'editor.lineHighlightBackground': themeValues.sys.neutral.decorDefault + '3F',
|
|
85
|
+
'editorCursor.foreground': themeValues.sys.primary.accentDefault,
|
|
86
|
+
'editorWhitespace.foreground': themeValues.sys.neutral.decorDefault,
|
|
87
|
+
'scrollbarSlider.background': themeValues.sys.neutral.accentDefault + '52',
|
|
88
|
+
'scrollbarSlider.hoverBackground': themeValues.sys.neutral.accentDefault + '7B',
|
|
89
|
+
'scrollbarSlider.activeBackground': themeValues.sys.neutral.accentDefault + 'A4',
|
|
90
|
+
'editorLineNumber.foreground': themeValues.sys.neutral.textLight,
|
|
91
|
+
'editorLineNumber.activeForeground': themeValues.sys.neutral.textMain
|
|
92
|
+
}
|
|
93
|
+
} : constants_1.DEFAULT_THEME_VALUES), [themeValues === null || themeValues === void 0 ? void 0 : themeValues.sys]);
|
|
94
|
+
const dark = (0, react_2.useMemo)(() => {
|
|
95
|
+
var _a;
|
|
96
|
+
return (0, utils_2.isDark)((_a = themeValues === null || themeValues === void 0 ? void 0 : themeValues.sys.available.complementary) !== null && _a !== void 0 ? _a : '');
|
|
97
|
+
}, [themeValues === null || themeValues === void 0 ? void 0 : themeValues.sys.available.complementary]);
|
|
98
|
+
monaco === null || monaco === void 0 ? void 0 : monaco.editor.defineTheme('snackDark', Object.assign(Object.assign({}, themeDataWithoutBase), {
|
|
99
|
+
base: 'vs-dark'
|
|
100
|
+
}));
|
|
101
|
+
monaco === null || monaco === void 0 ? void 0 : monaco.editor.defineTheme('snack', Object.assign(Object.assign({}, themeDataWithoutBase), {
|
|
102
|
+
base: 'vs'
|
|
103
|
+
}));
|
|
104
|
+
const mergedOptions = (0, react_2.useMemo)(() => Object.assign(Object.assign(Object.assign({}, constants_1.CODE_EDITOR_OPTIONS), (themeValues === null || themeValues === void 0 ? void 0 : themeValues.mono) ? {
|
|
105
|
+
fontSize: Number.parseFloat(themeValues.mono.body.s['font-size']),
|
|
106
|
+
fontWeight: themeValues.mono.body.s['font-weight'],
|
|
107
|
+
fontFamily: themeValues.mono.body.s['font-family']
|
|
108
|
+
} : constants_1.DEFAULT_THEME_OPTIONS.mono.s), options), [options, themeValues === null || themeValues === void 0 ? void 0 : themeValues.mono]);
|
|
109
|
+
return (0, jsx_runtime_1.jsx)("div", Object.assign({
|
|
110
|
+
className: className
|
|
111
|
+
}, (0, utils_1.extractSupportProps)(props), {
|
|
112
|
+
ref: setWrapperElement,
|
|
113
|
+
children: (0, jsx_runtime_1.jsx)(react_1.Editor, Object.assign({}, props, {
|
|
114
|
+
theme: (theme !== null && theme !== void 0 ? theme : dark) ? 'snackDark' : 'snack',
|
|
115
|
+
className: (0, classnames_1.default)({
|
|
116
|
+
[styles_module_scss_1.default.editor]: hasBackground
|
|
117
|
+
}),
|
|
118
|
+
loading: loading !== null && loading !== void 0 ? loading : (0, jsx_runtime_1.jsx)(loaders_1.Spinner, {}),
|
|
119
|
+
options: mergedOptions,
|
|
120
|
+
onMount: onEditorMount
|
|
121
|
+
}))
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CODE_EDITOR_OPTIONS = exports.THEME_VARS = exports.DEFAULT_THEME_OPTIONS = exports.DEFAULT_THEME_VALUES = void 0;
|
|
7
|
+
exports.DEFAULT_THEME_VALUES = {
|
|
8
|
+
semanticTokenColors: {
|
|
9
|
+
enumMember: {
|
|
10
|
+
foreground: '#6b9fe3'
|
|
11
|
+
},
|
|
12
|
+
'variable.constant': {
|
|
13
|
+
foreground: '#a2532f'
|
|
14
|
+
},
|
|
15
|
+
'variable.defaultLibrary': {
|
|
16
|
+
foreground: '#80461b'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
rules: [{
|
|
20
|
+
foreground: '#898989',
|
|
21
|
+
token: 'comment'
|
|
22
|
+
}, {
|
|
23
|
+
foreground: '#335747',
|
|
24
|
+
token: 'string'
|
|
25
|
+
}, {
|
|
26
|
+
foreground: '#80461b',
|
|
27
|
+
token: 'constant'
|
|
28
|
+
}, {
|
|
29
|
+
foreground: '#3280e8',
|
|
30
|
+
token: 'keyword'
|
|
31
|
+
}],
|
|
32
|
+
colors: {
|
|
33
|
+
'editor.background': '#00000000',
|
|
34
|
+
'editor.foreground': '#333333',
|
|
35
|
+
'editor.selectionBackground': '#decdfb',
|
|
36
|
+
'editor.lineHighlightBackground': '#decdfb',
|
|
37
|
+
'editorCursor.foreground': '#794ed3',
|
|
38
|
+
'editorWhitespace.foreground': '#dedede',
|
|
39
|
+
'scrollbarSlider.background': '#75757552',
|
|
40
|
+
'scrollbarSlider.hoverBackground': '#7575757B',
|
|
41
|
+
'scrollbarSlider.activeBackground': '#757575A4',
|
|
42
|
+
'editorLineNumber.foreground': '#333333',
|
|
43
|
+
'editorLineNumber.activeForeground': '#898989'
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.DEFAULT_THEME_OPTIONS = {
|
|
47
|
+
mono: {
|
|
48
|
+
s: {
|
|
49
|
+
fontWeight: '400',
|
|
50
|
+
fontSize: 12,
|
|
51
|
+
fontFamily: 'SB Sans Text Mono'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.THEME_VARS = {
|
|
56
|
+
sys: {
|
|
57
|
+
neutral: {
|
|
58
|
+
decorDefault: '--sys-neutral-decor-default',
|
|
59
|
+
accentDefault: '--sys-neutral-accent-default',
|
|
60
|
+
textMain: '--sys-neutral-text-main',
|
|
61
|
+
textLight: '--sys-neutral-text-light'
|
|
62
|
+
},
|
|
63
|
+
yellow: {
|
|
64
|
+
textSupport: '--sys-yellow-text-support'
|
|
65
|
+
},
|
|
66
|
+
available: {
|
|
67
|
+
complementary: '--sys-available-complementary'
|
|
68
|
+
},
|
|
69
|
+
blue: {
|
|
70
|
+
accentDefault: '--sys-blue-accent-default',
|
|
71
|
+
textLight: '--sys-blue-text-light'
|
|
72
|
+
},
|
|
73
|
+
orange: {
|
|
74
|
+
textSupport: '--sys-orange-text-support'
|
|
75
|
+
},
|
|
76
|
+
primary: {
|
|
77
|
+
decorHovered: '--sys-primary-decor-hovered',
|
|
78
|
+
accentDefault: '--sys-primary-accent-default'
|
|
79
|
+
},
|
|
80
|
+
green: {
|
|
81
|
+
textSupport: '--sys-green-text-support'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
mono: {
|
|
85
|
+
body: {
|
|
86
|
+
s: {
|
|
87
|
+
'font-weight': '--mono-body-s-font-weight',
|
|
88
|
+
'font-size': '--mono-body-s-font-size',
|
|
89
|
+
'font-family': '--mono-body-s-font-family'
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.CODE_EDITOR_OPTIONS = {
|
|
95
|
+
minimap: {
|
|
96
|
+
enabled: false
|
|
97
|
+
},
|
|
98
|
+
padding: {
|
|
99
|
+
top: 4,
|
|
100
|
+
bottom: 4
|
|
101
|
+
},
|
|
102
|
+
tabSize: 4,
|
|
103
|
+
scrollBeyondLastLine: false,
|
|
104
|
+
fixedOverflowWidgets: true,
|
|
105
|
+
lineDecorationsWidth: 4,
|
|
106
|
+
lineNumbersMinChars: 2,
|
|
107
|
+
scrollbar: {
|
|
108
|
+
verticalScrollbarSize: 8,
|
|
109
|
+
horizontalScrollbarSize: 8,
|
|
110
|
+
useShadows: false
|
|
111
|
+
},
|
|
112
|
+
contextmenu: false,
|
|
113
|
+
guides: {
|
|
114
|
+
indentation: false
|
|
115
|
+
}
|
|
116
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useCalculatedThemeValues = useCalculatedThemeValues;
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const utils_1 = require("@snack-uikit/utils");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
function getThemeVars(styles) {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
return function mapComputedTree(tree) {
|
|
13
|
+
if (typeof tree === 'string') {
|
|
14
|
+
return styles.getPropertyValue(tree);
|
|
15
|
+
}
|
|
16
|
+
const res = {};
|
|
17
|
+
Object.entries(tree).forEach(cur => {
|
|
18
|
+
res[cur[0]] = mapComputedTree(cur[1]);
|
|
19
|
+
});
|
|
20
|
+
return res;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function useCalculatedThemeValues(_ref) {
|
|
24
|
+
let {
|
|
25
|
+
stylesOriginNode,
|
|
26
|
+
themeName
|
|
27
|
+
} = _ref;
|
|
28
|
+
const [values, setValues] = (0, react_1.useState)(undefined);
|
|
29
|
+
const {
|
|
30
|
+
themeClassName
|
|
31
|
+
} = (0, utils_1.useThemeContext)();
|
|
32
|
+
const trigger = themeName !== null && themeName !== void 0 ? themeName : themeClassName;
|
|
33
|
+
(0, react_1.useEffect)(() => {
|
|
34
|
+
if (stylesOriginNode) {
|
|
35
|
+
const styles = getComputedStyle(stylesOriginNode);
|
|
36
|
+
setValues(getThemeVars(styles)(constants_1.THEME_VARS));
|
|
37
|
+
}
|
|
38
|
+
}, [stylesOriginNode, trigger]);
|
|
39
|
+
return values;
|
|
40
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./CodeEditor"), exports);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.rgb2hsl = rgb2hsl;
|
|
7
|
+
exports.isDark = isDark;
|
|
8
|
+
exports.initLoaderConfig = initLoaderConfig;
|
|
9
|
+
const react_1 = require("@monaco-editor/react");
|
|
10
|
+
function rgb2hsl(HTMLcolor) {
|
|
11
|
+
const r = parseInt(HTMLcolor.substring(1, 3), 16) / 255;
|
|
12
|
+
const g = parseInt(HTMLcolor.substring(3, 5), 16) / 255;
|
|
13
|
+
const b = parseInt(HTMLcolor.substring(5, 7), 16) / 255;
|
|
14
|
+
const max = Math.max(r, g, b),
|
|
15
|
+
min = Math.min(r, g, b);
|
|
16
|
+
let h, s;
|
|
17
|
+
const l = (max + min) / 2;
|
|
18
|
+
if (max === min) {
|
|
19
|
+
h = s = 0;
|
|
20
|
+
} else {
|
|
21
|
+
const d = max - min;
|
|
22
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
23
|
+
switch (max) {
|
|
24
|
+
case r:
|
|
25
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
26
|
+
break;
|
|
27
|
+
case g:
|
|
28
|
+
h = (b - r) / d + 2;
|
|
29
|
+
break;
|
|
30
|
+
case b:
|
|
31
|
+
h = (r - g) / d + 4;
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
h = 0;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
h /= 6;
|
|
38
|
+
}
|
|
39
|
+
return [h, s, l]; // H - цветовой тон, S - насыщенность, L - светлота
|
|
40
|
+
}
|
|
41
|
+
function isDark(color) {
|
|
42
|
+
const [h, _, l] = rgb2hsl(color);
|
|
43
|
+
return h < 0.55 && l >= 0.5 || h >= 0.55 && l >= 0.75;
|
|
44
|
+
}
|
|
45
|
+
function initLoaderConfig() {
|
|
46
|
+
if (!window) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
window['__snack-code-editor-loader-config__'] && react_1.loader.config(window['__snack-code-editor-loader-config__']);
|
|
52
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
exports.loader = void 0;
|
|
26
|
+
/**
|
|
27
|
+
Monaco loader defines the way how monaco will be loaded.
|
|
28
|
+
@see https://github.com/suren-atoyan/monaco-react/tree/master?tab=readme-ov-file#loader-config
|
|
29
|
+
*/
|
|
30
|
+
var react_1 = require("@monaco-editor/react");
|
|
31
|
+
Object.defineProperty(exports, "loader", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return react_1.loader;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
__exportStar(require("./components"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EditorProps } from '@monaco-editor/react';
|
|
2
|
+
import { WithSupportProps } from '@snack-uikit/utils';
|
|
3
|
+
export type CodeEditorProps = WithSupportProps<{
|
|
4
|
+
/**
|
|
5
|
+
* Название текущей темы. Значение не важно, важно что смена значения запускает пересчет стилей.
|
|
6
|
+
*/
|
|
7
|
+
themeName?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Включение/отключение псевдобекграунда
|
|
10
|
+
*/
|
|
11
|
+
hasBackground?: boolean;
|
|
12
|
+
}> & EditorProps;
|
|
13
|
+
export declare function CodeEditor({ themeName, className, theme, options, loading, hasBackground, onMount, ...props }: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export declare const DEFAULT_THEME_VALUES: {
|
|
2
|
+
semanticTokenColors: {
|
|
3
|
+
enumMember: {
|
|
4
|
+
foreground: string;
|
|
5
|
+
};
|
|
6
|
+
'variable.constant': {
|
|
7
|
+
foreground: string;
|
|
8
|
+
};
|
|
9
|
+
'variable.defaultLibrary': {
|
|
10
|
+
foreground: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
rules: {
|
|
14
|
+
foreground: string;
|
|
15
|
+
token: string;
|
|
16
|
+
}[];
|
|
17
|
+
colors: {
|
|
18
|
+
'editor.background': string;
|
|
19
|
+
'editor.foreground': string;
|
|
20
|
+
'editor.selectionBackground': string;
|
|
21
|
+
'editor.lineHighlightBackground': string;
|
|
22
|
+
'editorCursor.foreground': string;
|
|
23
|
+
'editorWhitespace.foreground': string;
|
|
24
|
+
'scrollbarSlider.background': string;
|
|
25
|
+
'scrollbarSlider.hoverBackground': string;
|
|
26
|
+
'scrollbarSlider.activeBackground': string;
|
|
27
|
+
'editorLineNumber.foreground': string;
|
|
28
|
+
'editorLineNumber.activeForeground': string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare const DEFAULT_THEME_OPTIONS: {
|
|
32
|
+
mono: {
|
|
33
|
+
s: {
|
|
34
|
+
fontWeight: string;
|
|
35
|
+
fontSize: number;
|
|
36
|
+
fontFamily: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare const THEME_VARS: {
|
|
41
|
+
sys: {
|
|
42
|
+
neutral: {
|
|
43
|
+
decorDefault: string;
|
|
44
|
+
accentDefault: string;
|
|
45
|
+
textMain: string;
|
|
46
|
+
textLight: string;
|
|
47
|
+
};
|
|
48
|
+
yellow: {
|
|
49
|
+
textSupport: string;
|
|
50
|
+
};
|
|
51
|
+
available: {
|
|
52
|
+
complementary: string;
|
|
53
|
+
};
|
|
54
|
+
blue: {
|
|
55
|
+
accentDefault: string;
|
|
56
|
+
textLight: string;
|
|
57
|
+
};
|
|
58
|
+
orange: {
|
|
59
|
+
textSupport: string;
|
|
60
|
+
};
|
|
61
|
+
primary: {
|
|
62
|
+
decorHovered: string;
|
|
63
|
+
accentDefault: string;
|
|
64
|
+
};
|
|
65
|
+
green: {
|
|
66
|
+
textSupport: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
mono: {
|
|
70
|
+
body: {
|
|
71
|
+
s: {
|
|
72
|
+
'font-weight': string;
|
|
73
|
+
'font-size': string;
|
|
74
|
+
'font-family': string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export declare const CODE_EDITOR_OPTIONS: {
|
|
80
|
+
minimap: {
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
};
|
|
83
|
+
padding: {
|
|
84
|
+
top: number;
|
|
85
|
+
bottom: number;
|
|
86
|
+
};
|
|
87
|
+
tabSize: number;
|
|
88
|
+
scrollBeyondLastLine: boolean;
|
|
89
|
+
fixedOverflowWidgets: boolean;
|
|
90
|
+
lineDecorationsWidth: number;
|
|
91
|
+
lineNumbersMinChars: number;
|
|
92
|
+
scrollbar: {
|
|
93
|
+
verticalScrollbarSize: number;
|
|
94
|
+
horizontalScrollbarSize: number;
|
|
95
|
+
useShadows: boolean;
|
|
96
|
+
};
|
|
97
|
+
contextmenu: boolean;
|
|
98
|
+
guides: {
|
|
99
|
+
indentation: boolean;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type UseCalculatedThemeValuesProps = {
|
|
2
|
+
stylesOriginNode: HTMLDivElement | null;
|
|
3
|
+
themeName?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function useCalculatedThemeValues({ stylesOriginNode, themeName }: UseCalculatedThemeValuesProps): {
|
|
6
|
+
sys: {
|
|
7
|
+
neutral: {
|
|
8
|
+
decorDefault: string;
|
|
9
|
+
accentDefault: string;
|
|
10
|
+
textMain: string;
|
|
11
|
+
textLight: string;
|
|
12
|
+
};
|
|
13
|
+
yellow: {
|
|
14
|
+
textSupport: string;
|
|
15
|
+
};
|
|
16
|
+
available: {
|
|
17
|
+
complementary: string;
|
|
18
|
+
};
|
|
19
|
+
blue: {
|
|
20
|
+
accentDefault: string;
|
|
21
|
+
textLight: string;
|
|
22
|
+
};
|
|
23
|
+
orange: {
|
|
24
|
+
textSupport: string;
|
|
25
|
+
};
|
|
26
|
+
primary: {
|
|
27
|
+
decorHovered: string;
|
|
28
|
+
accentDefault: string;
|
|
29
|
+
};
|
|
30
|
+
green: {
|
|
31
|
+
textSupport: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
mono: {
|
|
35
|
+
body: {
|
|
36
|
+
s: {
|
|
37
|
+
'font-weight': string;
|
|
38
|
+
'font-size': string;
|
|
39
|
+
'font-family': string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
} | undefined;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CodeEditor';
|
package/package.json
CHANGED
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.2.
|
|
7
|
+
"version": "0.2.4-preview-1f246c4a.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
11
11
|
"*.woff2"
|
|
12
12
|
],
|
|
13
13
|
"description": "",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"types": "./dist/esm/index.d.ts",
|
|
15
|
+
"main": "./dist/cjs/index.js",
|
|
16
|
+
"module": "./dist/esm/index.js",
|
|
16
17
|
"homepage": "https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/tree/master/packages/code-editor",
|
|
17
18
|
"repository": {
|
|
18
19
|
"type": "git",
|
|
@@ -24,7 +25,8 @@
|
|
|
24
25
|
"Nikita Ershov <niershov@cloud.ru>"
|
|
25
26
|
],
|
|
26
27
|
"files": [
|
|
27
|
-
"dist",
|
|
28
|
+
"dist/cjs",
|
|
29
|
+
"dist/esm",
|
|
28
30
|
"src",
|
|
29
31
|
"./CHANGELOG.md",
|
|
30
32
|
"./LICENSE"
|
|
@@ -33,9 +35,9 @@
|
|
|
33
35
|
"scripts": {},
|
|
34
36
|
"dependencies": {
|
|
35
37
|
"@monaco-editor/react": "4.6.0",
|
|
36
|
-
"@snack-uikit/loaders": "0.5.
|
|
37
|
-
"@snack-uikit/utils": "3.
|
|
38
|
+
"@snack-uikit/loaders": "0.5.4-preview-1f246c4a.0",
|
|
39
|
+
"@snack-uikit/utils": "3.4.1-preview-1f246c4a.0",
|
|
38
40
|
"classnames": "2.5.1"
|
|
39
41
|
},
|
|
40
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "a185a55c0722b19f70dd168cf299e6f53a0fd93f"
|
|
41
43
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
.editor{
|
|
2
|
-
background-color:inherit;
|
|
3
|
-
}
|
|
4
|
-
.editor::after{
|
|
5
|
-
pointer-events:none;
|
|
6
|
-
content:"";
|
|
7
|
-
position:absolute;
|
|
8
|
-
top:0;
|
|
9
|
-
bottom:0;
|
|
10
|
-
width:100%;
|
|
11
|
-
opacity:var(--opacity-a004, 0.04);
|
|
12
|
-
background-color:var(--sys-neutral-accent-default, #787b8a);
|
|
13
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|