@codecademy/codebytes 0.1.1-alpha.ddee0b.0 → 0.2.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 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
- ### [0.1.1-alpha.ddee0b.0](https://github.com/Codecademy/client-modules/compare/@codecademy/codebytes@0.1.0...@codecademy/codebytes@0.1.1-alpha.ddee0b.0) (2022-01-03)
6
+ ## [0.2.0](https://github.com/Codecademy/client-modules/compare/@codecademy/codebytes@0.1.0...@codecademy/codebytes@0.2.0) (2022-01-04)
7
7
 
8
- **Note:** Version bump only for package @codecademy/codebytes
9
8
 
9
+ ### Features
10
10
 
11
+ * **Codebytes:** add editor and drawers disc 351 ([#14](https://github.com/Codecademy/client-modules/issues/14)) ([e84e265](https://github.com/Codecademy/client-modules/commit/e84e265e4cf4bf8360830ebf2dbea930ab503c9c))
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.1.1-alpha.ddee0b.0",
4
+ "version": "0.2.0",
5
5
  "author": "Codecademy Engineering <dev@codecademy.com>",
6
6
  "sideEffects": [
7
7
  "**/*.css",
@@ -44,5 +44,5 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "a32b92d7fe89f0553729f4d82d9965e1d56340ec"
47
+ "gitHead": "db6be3e2ec6108c6eddb25c04097ed959c67db76"
48
48
  }
package/src/api.ts CHANGED
@@ -1,25 +1,28 @@
1
1
  import type { languageOption } from './consts';
2
2
 
3
- interface Response {
4
- stderr: string;
5
- stdout: string;
6
- exit_code: number;
7
- }
8
-
9
- interface PostSnippetData {
10
- language: languageOption;
11
- code: string;
12
- }
3
+ interface Response {
4
+ stderr: string;
5
+ stdout: string;
6
+ exit_code: number;
7
+ }
13
8
 
14
- export const postSnippet = async (data: PostSnippetData, snippetsBaseUrl?: string): Promise<Response> => {
15
- const snippetsEndpoint = `https://${snippetsBaseUrl}/snippets`;
9
+ interface PostSnippetData {
10
+ language: languageOption;
11
+ code: string;
12
+ }
16
13
 
17
- const response = await fetch(snippetsEndpoint, {
18
- method: 'POST',
19
- body: JSON.stringify(data),
20
- headers: {
21
- 'x-codecademy-user-id': 'codebytes-anon-user',
22
- },
23
- });
24
- return response.json();
25
- };
14
+ export const postSnippet = async (
15
+ data: PostSnippetData,
16
+ snippetsBaseUrl?: string
17
+ ): Promise<Response> => {
18
+ const snippetsEndpoint = `https://${snippetsBaseUrl}/snippets`;
19
+
20
+ const response = await fetch(snippetsEndpoint, {
21
+ method: 'POST',
22
+ body: JSON.stringify(data),
23
+ headers: {
24
+ 'x-codecademy-user-id': 'codebytes-anon-user',
25
+ },
26
+ });
27
+ return response.json();
28
+ };
package/src/editor.tsx CHANGED
@@ -62,10 +62,7 @@ export const Editor: React.FC<EditorProps> = ({
62
62
  .writeText(text)
63
63
  // eslint-disable-next-line no-console
64
64
  .catch(() => console.error('Failed to copy'));
65
- onCopy?.(
66
- text,
67
- language
68
- ); /* TODO: pass in onCopyBBCodeblock behavior from the future version we migrate to Next.js */
65
+ onCopy?.(text, language);
69
66
  setIsCodeByteCopied(true);
70
67
  }
71
68
  };
package/src/index.tsx CHANGED
@@ -36,7 +36,7 @@ export interface CodeByteEditorProps {
36
36
  hideCopyButton: boolean;
37
37
  onCopy?: (text: string, language: string) => void;
38
38
  isIFrame?: boolean;
39
- snippetsBaseUrl?: string;
39
+ snippetsBaseUrl?: string /* TODO in DISC-353: Determine best way to host and include snippets endpoint for both staging and production in both the monolith and next.js repo. */;
40
40
  onTextChange?: (text: string) => void;
41
41
  }
42
42
 
@@ -46,7 +46,7 @@ export const CodeByteEditor: React.FC<CodeByteEditorProps> = ({
46
46
  hideCopyButton,
47
47
  onCopy,
48
48
  isIFrame = false,
49
- snippetsBaseUrl = process.env.CONTAINER_API_BASE,
49
+ snippetsBaseUrl = '',
50
50
  onTextChange,
51
51
  }) => {
52
52
  const [text, setText] = useState<string>(initialText);
package/src/theme.d.ts CHANGED
@@ -2,4 +2,4 @@ import { CoreTheme } from '@codecademy/gamut-styles';
2
2
 
3
3
  declare module '@emotion/react' {
4
4
  export interface Theme extends CoreTheme {}
5
- }
5
+ }