- remove StepType, type column, and type field from step entity and DTOs - remove executeLoginStep, executeSignStep, executeExecStep from scheduler - inline exec logic directly in executeStepRun; all steps run execCode - remove AuthService, EnvironmentService, runEnvironments from scheduler - remove type selector from CreateStepPage and EditStepPage - remove type badge column from ScenarioDetailPage - fix useEffect dependency arrays in RunDetailPage (FINAL, id, runId, polling) - fix duplicate /snippets proxy key in vite.config.ts - remove unused escapeHtml export from hljs.ts
28 lines
705 B
TypeScript
28 lines
705 B
TypeScript
import { useMemo } from 'react';
|
|
import hljs from '../../lib/hljs';
|
|
import styles from './CodeBlock.module.css';
|
|
|
|
export interface CodeBlockProps {
|
|
code: string;
|
|
language?: string;
|
|
}
|
|
|
|
export function CodeBlock({ code, language = 'javascript' }: CodeBlockProps) {
|
|
const highlighted = useMemo(() => {
|
|
try {
|
|
return hljs.highlight(code, { language }).value;
|
|
} catch {
|
|
return code.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
}
|
|
}, [code, language]);
|
|
|
|
return (
|
|
<pre className={styles.pre}>
|
|
<code
|
|
className={`${styles.code} hljs language-${language}`}
|
|
dangerouslySetInnerHTML={{ __html: highlighted }}
|
|
/>
|
|
</pre>
|
|
);
|
|
}
|