mirror of
https://github.com/jaronpate/unicord.git
synced 2026-10-18 21:47:40 +00:00
feat: Migrate CodeExample to @monaco-editor/react for Turbopack compatibility
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import * as monaco from 'monaco-editor';
|
import Editor from "@monaco-editor/react";
|
||||||
import styles from './CodeExample.module.css';
|
import styles from './CodeExample.module.css';
|
||||||
|
|
||||||
const exampleCode = `\
|
const exampleCode = `\
|
||||||
@@ -29,27 +29,24 @@ client.chatCommands.register('ping', (context: Context, args) => {
|
|||||||
client.connect();`;
|
client.connect();`;
|
||||||
|
|
||||||
export default function CodeExample() {
|
export default function CodeExample() {
|
||||||
const editorRef = useRef<HTMLDivElement>(null);
|
return (
|
||||||
|
<div className={styles.editorContainer}>
|
||||||
useEffect(() => {
|
<Editor
|
||||||
if (editorRef.current) {
|
height="400px"
|
||||||
const editor = monaco.editor.create(editorRef.current, {
|
defaultLanguage="typescript"
|
||||||
value: exampleCode,
|
defaultValue={exampleCode}
|
||||||
language: 'typescript',
|
theme="vs-dark"
|
||||||
theme: 'vs-dark',
|
options={{
|
||||||
minimap: { enabled: false },
|
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
automaticLayout: true,
|
minimap: { enabled: false },
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
lineNumbers: 'on',
|
lineNumbers: 'on',
|
||||||
scrollBeyondLastLine: false,
|
scrollBeyondLastLine: false,
|
||||||
roundedSelection: false,
|
roundedSelection: false,
|
||||||
padding: { top: 16, bottom: 16 },
|
padding: { top: 16, bottom: 16 },
|
||||||
});
|
automaticLayout: true,
|
||||||
|
}}
|
||||||
return () => editor.dispose();
|
/>
|
||||||
}
|
</div>
|
||||||
}, []);
|
);
|
||||||
|
|
||||||
return <div className={styles.editorContainer} ref={editorRef} />;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user