You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
monaco-editor/website/playground/new-samples/extending-language-services/codelens-provider-example/sample.js

33 lines
887 B
JavaScript

var editor = monaco.editor.create(document.getElementById("container"), {
value: "{\n\t\"dependencies\": {\n\t\t\n\t}\n}\n",
language: "json"
});
var commandId = editor.addCommand(0, function() {
// services available in `ctx`
alert('my command is executing!');
}, '');
monaco.languages.registerCodeLensProvider('json', {
provideCodeLenses: function(model, token) {
return [
{
range: {
startLineNumber: 1,
startColumn: 1,
endLineNumber: 2,
endColumn: 1
},
id: "First Line",
command: {
id: commandId,
title: "First Line"
}
}
];
},
resolveCodeLens: function(model, codeLens, token) {
return codeLens;
}
});