增加代码编辑器表单组件
This commit is contained in:
parent
826c2d1a76
commit
e5e20a4dbb
@ -162,7 +162,13 @@ export const TemplateEditor: React.FC<TemplateEditorProps> = ({
|
||||
|
||||
// 设置自动完成
|
||||
monaco.languages.registerCompletionItemProvider('freemarker', {
|
||||
provideCompletionItems: (model, position) => {
|
||||
// 使用宽松的类型以兼容不同版本的 monaco 类型定义
|
||||
provideCompletionItems: (
|
||||
model: any,
|
||||
position: any,
|
||||
context?: any,
|
||||
token?: any
|
||||
) => {
|
||||
const suggestions = [
|
||||
// FreeMarker 指令
|
||||
...['if', 'list', 'assign', 'include', 'macro'].map(keyword => ({
|
||||
@ -183,7 +189,7 @@ export const TemplateEditor: React.FC<TemplateEditorProps> = ({
|
||||
}))
|
||||
];
|
||||
|
||||
return { suggestions };
|
||||
return { suggestions } as any; // 兼容 CompletionList 类型
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -192,8 +198,12 @@ export const TemplateEditor: React.FC<TemplateEditorProps> = ({
|
||||
registerFreeMarker();
|
||||
}, [variables]);
|
||||
|
||||
const handleEditorDidMount = (editor: editor.IStandaloneCodeEditor) => {
|
||||
editorRef.current = editor;
|
||||
const handleEditorDidMount = (
|
||||
ed: editor.IStandaloneCodeEditor,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
monacoInstance?: unknown
|
||||
) => {
|
||||
editorRef.current = ed;
|
||||
};
|
||||
|
||||
const getVariableTypeColor = (type: string) => {
|
||||
@ -220,11 +230,11 @@ export const TemplateEditor: React.FC<TemplateEditorProps> = ({
|
||||
|
||||
<div className="flex-1 overflow-hidden">
|
||||
<Editor
|
||||
ref={editorRef}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
language="freemarker"
|
||||
theme="vs-light"
|
||||
onMount={handleEditorDidMount as any}
|
||||
options={{
|
||||
minimap: { enabled: false },
|
||||
scrollBeyondLastLine: false,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user