sample.js 1010 B

123456789101112131415161718192021222324252627282930313233343536
  1. var editor = monaco.editor.create(document.getElementById("container"), {
  2. value: "{\n\t\"dependencies\": {\n\t\t\n\t}\n}\n",
  3. language: "json"
  4. });
  5. var commandId = editor.addCommand(0, function () {
  6. // services available in `ctx`
  7. alert('my command is executing!');
  8. }, '');
  9. monaco.languages.registerCodeLensProvider('json', {
  10. provideCodeLenses: function (model, token) {
  11. return {
  12. lenses: [
  13. {
  14. range: {
  15. startLineNumber: 1,
  16. startColumn: 1,
  17. endLineNumber: 2,
  18. endColumn: 1
  19. },
  20. id: "First Line",
  21. command: {
  22. id: commandId,
  23. title: "First Line"
  24. }
  25. }
  26. ],
  27. dispose: () => {}
  28. };
  29. },
  30. resolveCodeLens: function (model, codeLens, token) {
  31. return codeLens;
  32. }
  33. });