scripting added
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 8s

This commit is contained in:
2026-02-09 21:56:12 +01:00
parent 69abb95140
commit 317946c7b7
9 changed files with 187 additions and 6 deletions

View File

@@ -0,0 +1,54 @@
import Prism from 'prismjs';
import 'prismjs/components/prism-python';
import 'prismjs/themes/prism.css';
import { useCallback, useMemo } from 'react';
import Editor from 'react-simple-code-editor';
// Props for the editor
export type PythonEditorProps = {
value: string;
onChange: (code: string) => void;
readOnly?: boolean;
className?: string;
height?: string | number; // e.g. '200px' or 200
};
export default function PythonEditor({
value,
onChange,
readOnly = false,
height = 480,
className = '',
}: PythonEditorProps) {
const highlight = useCallback((code: string) => {
try {
return Prism.highlight(code, Prism.languages.python, 'python');
} catch (e) {
return code;
}
}, []);
const editorStyle = useMemo(
() => ({
fontFamily: '"JetBrains Mono", "Fira Code", monospace',
fontSize: 14,
height: typeof height === 'number' ? `${height}px` : height,
}),
[height],
);
return (
<div className={`python-editor ${className}`}>
<Editor
value={value}
onValueChange={(code) => onChange(code)}
highlight={highlight}
padding={12}
preClassName="language-python"
textareaId="python-editor"
style={editorStyle}
readOnly={readOnly}
/>
</div>
);
}