| 11 | import styles from './CodeEditor.module.css'; |
| 12 | |
| 13 | const prettify = async (value: string) => { |
| 14 | const formattedCode = await prettier |
| 15 | .format(value, { |
| 16 | parser: 'meriyah', |
| 17 | plugins: [meriyahParser, estreePlugin as Plugin], |
| 18 | printWidth: 120, |
| 19 | tabWidth: 2, |
| 20 | useTabs: false, |
| 21 | semi: false, |
| 22 | bracketSpacing: false, |
| 23 | arrowParens: 'avoid' as const, |
| 24 | endOfLine: 'lf' as const, |
| 25 | }) |
| 26 | .catch(() => value); |
| 27 | |
| 28 | return formattedCode.replace(/^;/, '').replace(/;$/, ''); |
| 29 | }; |
| 30 | |
| 31 | export const CodeEditor = () => { |
| 32 | const editorRef = useRef<Parameters<OnMount>[0] | null>(null); |