-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathCodeEditor.tsx
More file actions
37 lines (34 loc) · 973 Bytes
/
CodeEditor.tsx
File metadata and controls
37 lines (34 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import * as React from 'react';
import { CodeHighlighter } from '@mui/internal-docs-infra/CodeHighlighter';
import { createParseSource } from '@mui/internal-docs-infra/pipeline/parseSource';
import { CodeProvider } from '@mui/internal-docs-infra/CodeProvider';
import { CodeController } from './CodeController';
import { CodeEditorContent } from './CodeEditorContent';
const initialCode = {
Default: {
url: 'file://live-example.js',
fileName: 'live-example.js',
source: `// Welcome to the live code editor!
function greet(name) {
return \`Hello, \${name}!\`;
}
`,
},
};
export function CodeEditor() {
return (
// @focus-start
<CodeProvider>
<CodeController>
<CodeHighlighter
url={initialCode.Default.url}
Content={CodeEditorContent}
code={initialCode}
controlled
sourceParser={createParseSource()}
/>
</CodeController>
</CodeProvider>
// @focus-end
);
}