Closed
Description
Hello, in my project, completion is not workfing while other options work well. It is strange and i can't figure it out what the problem is.
Here is my code:
import React, { FC, useEffect, useRef } from 'react';
import { editor, Environment } from 'monaco-editor/esm/vs/editor/editor.api';
import { setDiagnosticsOptions } from 'monaco-yaml';
import 'monaco-editor';
// eslint-disable-next-line import/no-webpack-loader-syntax
import EditorWorker from 'worker-loader!monaco-editor/esm/vs/editor/editor.worker.js';
// eslint-disable-next-line import/no-webpack-loader-syntax
import YamlWorker from 'worker-loader!monaco-yaml/lib/esm/yaml.worker.js';
import classes from './editeNodeAttr.module.less';
declare global {
interface Window {
MonacoEnvironment: Environment;
}
}
window.MonacoEnvironment = {
getWorker(moduleId, label) {
if (label === 'yaml') {
return new YamlWorker();
}
return new EditorWorker();
},
};
setDiagnosticsOptions({
validate: true,
enableSchemaRequest: true,
format: true,
hover: true,
completion: true,
schemas: [
{
uri: 'http://myserver/foo-schema.json',
fileMatch: ['*'],
schema: {
id: 'http://myserver/foo-schema.json',
type: 'object',
properties: {
boolean: {
description: 'Are boolean supported?',
type: 'boolean',
},
enum: {
description: 'Pick your starter',
enum: ['Bulbasaur', 'Squirtle', 'Charmander', 'Pikachu'],
},
},
},
},
],
});
const YamlEditTest: FC = () => {
const ref = useRef(null);
const defaultValue = `enum: `;
useEffect(() => {
const yamlInstance = editor.create(ref.current, {
automaticLayout: true,
value: defaultValue,
language: 'yaml',
fontSize: 15,
});
yamlInstance.onDidChangeModelContent(event => {
const markers = editor.getModelMarkers({});
console.log(markers);
});
}, [defaultValue]);
return <div className={classes.yamlEdite} ref={ref} style={{ border: '1px solid #d9d9d9' }} />;
};
export default YamlEditTest;
when i hover, it shows the tips:
But it can not complete the value according to the enum configuration, like the example in the monaco-yaml.js.org:
The version of monaco-editor is 0.27.0 and monaco-yaml is 3.0.1.
Metadata
Metadata
Assignees
Labels
No labels