* feat: pnpm new * Refactor build and release workflows, update dependencies Switch build scripts and workflows from npm to pnpm, update build and artifact paths, and simplify release workflow by removing version detection and changelog steps. Add new dependencies (silk-wasm, express, ws, node-pty-prebuilt-multiarch), update exports in package.json files, and add vite config for napcat-framework. Also, rename manifest.json for framework package and fix static asset copying in shell build config.
56 lines
1.1 KiB
TypeScript
56 lines
1.1 KiB
TypeScript
import Editor, { OnMount, loader } from '@monaco-editor/react';
|
|
|
|
import React from 'react';
|
|
|
|
import { useTheme } from '@/hooks/use-theme';
|
|
|
|
import monaco from '@/monaco';
|
|
|
|
loader.config({
|
|
monaco,
|
|
paths: {
|
|
vs: '/webui/monaco-editor/min/vs',
|
|
},
|
|
});
|
|
|
|
loader.config({
|
|
'vs/nls': {
|
|
availableLanguages: { '*': 'zh-cn' },
|
|
},
|
|
});
|
|
|
|
export interface CodeEditorProps extends React.ComponentProps<typeof Editor> {
|
|
test?: string
|
|
}
|
|
|
|
export type CodeEditorRef = monaco.editor.IStandaloneCodeEditor;
|
|
|
|
const CodeEditor = React.forwardRef<CodeEditorRef, CodeEditorProps>(
|
|
(props, ref) => {
|
|
const { isDark } = useTheme();
|
|
|
|
const handleEditorDidMount: OnMount = (editor, monaco) => {
|
|
if (ref) {
|
|
if (typeof ref === 'function') {
|
|
ref(editor);
|
|
} else {
|
|
(ref as React.RefObject<CodeEditorRef>).current = editor;
|
|
}
|
|
}
|
|
if (props.onMount) {
|
|
props.onMount(editor, monaco);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Editor
|
|
{...props}
|
|
onMount={handleEditorDidMount}
|
|
theme={isDark ? 'vs-dark' : 'light'}
|
|
/>
|
|
);
|
|
}
|
|
);
|
|
|
|
export default CodeEditor;
|