mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-05-19 04:08:48 +00:00
37 lines
704 B
JavaScript
37 lines
704 B
JavaScript
const value = `
|
|
number: 0xfe
|
|
boolean: true
|
|
`;
|
|
|
|
async function create() {
|
|
// Dynamic import is possible
|
|
const { default: monaco } = await import('./main.js');
|
|
|
|
// Define schema first
|
|
monaco.languages.yaml.yamlDefaults.setDiagnosticsOptions({
|
|
schemas: [
|
|
{
|
|
fileMatch: ['*'],
|
|
uri: 'my-schema.json',
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
number: {
|
|
description: 'number property',
|
|
type: 'number',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
});
|
|
|
|
// Create editor
|
|
monaco.editor.create(document.querySelector('.editor'), {
|
|
language: 'yaml',
|
|
tabSize: 2,
|
|
value,
|
|
});
|
|
}
|
|
|
|
create();
|