@codecademy/codebytes 1.4.0-alpha.334191b9b7.0 → 1.4.0-alpha.5fbff9c648.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/MonacoEditor/index.js +42 -29
- package/package.json +3 -3
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
1
7
|
// DO NOT CHANGE ANYTHING HERE
|
|
2
8
|
// This component is part of the Codebytes MVP and only includes basic configuration around theming
|
|
3
9
|
// We are working on a monaco package in client-modules that has more configuration around themes and languages
|
|
@@ -5,45 +11,52 @@
|
|
|
5
11
|
|
|
6
12
|
import ReactMonacoEditor from '@monaco-editor/react';
|
|
7
13
|
import React, { useCallback, useRef } from 'react';
|
|
8
|
-
import
|
|
14
|
+
import { useMeasure } from 'react-use';
|
|
9
15
|
import { dark } from './theme';
|
|
10
|
-
import { jsx as _jsx
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
17
|
export const SimpleMonacoEditor = _ref => {
|
|
12
18
|
let value = _ref.value,
|
|
13
19
|
language = _ref.language,
|
|
14
20
|
onChange = _ref.onChange;
|
|
21
|
+
const _useMeasure = useMeasure(),
|
|
22
|
+
_useMeasure2 = _slicedToArray(_useMeasure, 2),
|
|
23
|
+
ref = _useMeasure2[0],
|
|
24
|
+
_useMeasure2$ = _useMeasure2[1],
|
|
25
|
+
width = _useMeasure2$.width,
|
|
26
|
+
height = _useMeasure2$.height;
|
|
15
27
|
const editorRef = useRef(null);
|
|
16
28
|
const editorWillMount = useCallback((editor, monaco) => {
|
|
17
29
|
editorRef.current = editor;
|
|
18
30
|
monaco.editor.defineTheme('dark', dark);
|
|
19
31
|
monaco.editor.setTheme('dark');
|
|
20
32
|
}, []);
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
width
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}), /*#__PURE__*/_jsx(ReactMonacoEditor, {
|
|
33
|
-
onMount: editorWillMount,
|
|
34
|
-
onChange: onChange,
|
|
35
|
-
options: {
|
|
36
|
-
minimap: {
|
|
37
|
-
enabled: false
|
|
38
|
-
}
|
|
33
|
+
return (
|
|
34
|
+
/*#__PURE__*/
|
|
35
|
+
// @ts-expect-error A known issue that should be fixed in the future https://github.com/streamich/react-use/pull/2672
|
|
36
|
+
_jsx("div", {
|
|
37
|
+
ref: ref,
|
|
38
|
+
style: {
|
|
39
|
+
width: '100%',
|
|
40
|
+
height: '100%'
|
|
39
41
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
children: /*#__PURE__*/_jsx(ReactMonacoEditor, {
|
|
43
|
+
onMount: editorWillMount,
|
|
44
|
+
onChange: onChange,
|
|
45
|
+
options: {
|
|
46
|
+
minimap: {
|
|
47
|
+
enabled: false
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
theme: "vs-dark",
|
|
51
|
+
value: value,
|
|
52
|
+
height: height,
|
|
53
|
+
width: width,
|
|
54
|
+
language: language
|
|
55
|
+
// beforeMount is a required prop for the Monaco editor. If it is not provided, the editor will not be initialized correctly.
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
57
|
+
,
|
|
58
|
+
beforeMount: () => {}
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
);
|
|
49
62
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/codebytes",
|
|
3
3
|
"description": "Codebytes Editor",
|
|
4
|
-
"version": "1.4.0-alpha.
|
|
4
|
+
"version": "1.4.0-alpha.5fbff9c648.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@monaco-editor/react": "^4.4.5",
|
|
8
|
-
"react-
|
|
8
|
+
"react-use": "15.3.8"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist/**"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@codecademy/gamut": "*",
|
|
18
18
|
"@codecademy/gamut-icons": "*",
|
|
19
19
|
"@codecademy/gamut-styles": "*",
|
|
20
|
-
"@codecademy/tracking": "1.4.0-alpha.
|
|
20
|
+
"@codecademy/tracking": "1.4.0-alpha.5fbff9c648.0",
|
|
21
21
|
"@codecademy/variance": "*",
|
|
22
22
|
"@emotion/styled": "^11.3.0",
|
|
23
23
|
"monaco-editor": "*",
|