@codecademy/codebytes 0.2.1-alpha.f45f38.0 → 0.3.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 +3 -2
- package/package.json +3 -5
- package/src/MonacoEditor/index.tsx +5 -7
- package/src/editor.tsx +1 -2
- package/src/index.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
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
|
-
|
|
6
|
+
## [0.3.0](https://github.com/Codecademy/client-modules/compare/@codecademy/codebytes@0.2.0...@codecademy/codebytes@0.3.0) (2022-01-12)
|
|
7
7
|
|
|
8
|
-
**Note:** Version bump only for package @codecademy/codebytes
|
|
9
8
|
|
|
9
|
+
### Features
|
|
10
10
|
|
|
11
|
+
* **Codebytes:** add simple monaco editor disc 353 ([#16](https://github.com/Codecademy/client-modules/issues/16)) ([eec98ba](https://github.com/Codecademy/client-modules/commit/eec98ba9aad45f07fb5f3417e3da1e1935985deb))
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/codebytes",
|
|
3
3
|
"description": "Codebytes Code Editor",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.css",
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"@codecademy/variance": "*",
|
|
27
27
|
"@emotion/react": "^11.4.0",
|
|
28
28
|
"@emotion/styled": "^11.3.0",
|
|
29
|
-
"@loadable/component": "^5.13.1",
|
|
30
29
|
"@monaco-editor/react": "4.3.1",
|
|
31
30
|
"monaco-editor": ">= 0.25.0 < 1",
|
|
32
31
|
"react-resize-observer": "1.1.1"
|
|
@@ -44,11 +43,10 @@
|
|
|
44
43
|
"@emotion/jest": "^11.3.0",
|
|
45
44
|
"@testing-library/dom": "^7.31.2",
|
|
46
45
|
"@testing-library/react": "^11.0.4",
|
|
47
|
-
"@types/loadable__component": "^5.13.2"
|
|
48
|
-
"monaco-editor-webpack-plugin": "1.9.1"
|
|
46
|
+
"@types/loadable__component": "^5.13.2"
|
|
49
47
|
},
|
|
50
48
|
"publishConfig": {
|
|
51
49
|
"access": "public"
|
|
52
50
|
},
|
|
53
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "7845d303c2191ed8d56b06edbd6aae9741d68aeb"
|
|
54
52
|
}
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
// We are working on a monaco package in client-modules that has more configuration around themes and languages
|
|
4
4
|
// Monaco as a shared package RFC https://www.notion.so/codecademy/Monaco-editor-as-a-shared-package-1f4484db165b4abc8394c3556451ef6a
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
6
|
+
import ReactMonacoEditor, { OnMount } from '@monaco-editor/react';
|
|
7
|
+
import { editor } from 'monaco-editor/esm/vs/editor/editor.api';
|
|
8
8
|
import React, { useCallback, useRef } from 'react';
|
|
9
9
|
import ResizeObserver from 'react-resize-observer';
|
|
10
10
|
|
|
11
11
|
import { dark } from './theme';
|
|
12
12
|
import { Monaco } from './types';
|
|
13
13
|
|
|
14
|
-
const ReactMonacoEditor = loadable(() => import('@monaco-editor/react'));
|
|
15
|
-
|
|
16
14
|
export type SimpleMonacoEditorProps = {
|
|
17
15
|
value: string;
|
|
18
16
|
language: string;
|
|
@@ -26,7 +24,7 @@ export const SimpleMonacoEditor: React.FC<SimpleMonacoEditorProps> = ({
|
|
|
26
24
|
language,
|
|
27
25
|
onChange,
|
|
28
26
|
}) => {
|
|
29
|
-
const editorRef = useRef<
|
|
27
|
+
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
|
|
30
28
|
const editorWillMount = useCallback(
|
|
31
29
|
(editor: ThemedEditor, monaco: Monaco) => {
|
|
32
30
|
editorRef.current = editor;
|
|
@@ -39,7 +37,7 @@ export const SimpleMonacoEditor: React.FC<SimpleMonacoEditorProps> = ({
|
|
|
39
37
|
<>
|
|
40
38
|
<ResizeObserver
|
|
41
39
|
onResize={({ height, width }) => {
|
|
42
|
-
editorRef.current?.
|
|
40
|
+
editorRef.current?.layout({
|
|
43
41
|
height,
|
|
44
42
|
width,
|
|
45
43
|
});
|
|
@@ -49,7 +47,7 @@ export const SimpleMonacoEditor: React.FC<SimpleMonacoEditorProps> = ({
|
|
|
49
47
|
onMount={editorWillMount}
|
|
50
48
|
onChange={onChange}
|
|
51
49
|
options={{ minimap: { enabled: false } }}
|
|
52
|
-
theme="dark"
|
|
50
|
+
theme="vs-dark"
|
|
53
51
|
value={value}
|
|
54
52
|
language={language}
|
|
55
53
|
/>
|
package/src/editor.tsx
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
ToolTip,
|
|
7
7
|
} from '@codecademy/gamut';
|
|
8
8
|
import { CopyIcon } from '@codecademy/gamut-icons';
|
|
9
|
-
import { colors } from '@codecademy/gamut-styles';
|
|
10
9
|
import styled from '@emotion/styled';
|
|
11
10
|
import React, { useState } from 'react';
|
|
12
11
|
|
|
@@ -25,7 +24,7 @@ const Output = styled.pre<{ hasError: boolean }>`
|
|
|
25
24
|
overflow: auto;
|
|
26
25
|
${({ hasError, theme }) => `
|
|
27
26
|
color: ${hasError ? theme.colors.orange : theme.colors.white};
|
|
28
|
-
background-color: ${colors['
|
|
27
|
+
background-color: ${theme.colors['navy-900']};
|
|
29
28
|
`}
|
|
30
29
|
`;
|
|
31
30
|
|
package/src/index.tsx
CHANGED
|
@@ -46,7 +46,7 @@ export const CodeByteEditor: React.FC<CodeByteEditorProps> = ({
|
|
|
46
46
|
hideCopyButton,
|
|
47
47
|
onCopy,
|
|
48
48
|
isIFrame = false,
|
|
49
|
-
snippetsBaseUrl =
|
|
49
|
+
snippetsBaseUrl = process.env.CONTAINER_API_BASE,
|
|
50
50
|
onTextChange,
|
|
51
51
|
}) => {
|
|
52
52
|
const [text, setText] = useState<string>(initialText);
|