mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 18:32:56 +01:00
Add code sample for codelens helper
This commit is contained in:
parent
4c208b788c
commit
a7b44c7331
6 changed files with 118 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
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;
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue