extending-language-services-codelens-provider-example.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!DOCTYPE html>
  2. <!-- THIS IS A GENERATED FILE VIA `npm run simpleserver` -->
  3. <html>
  4. <head>
  5. <base href="..">
  6. <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  7. </head>
  8. <body>
  9. <style>
  10. /*----------------------------------------SAMPLE CSS START*/
  11. /*----------------------------------------SAMPLE CSS END*/
  12. </style>
  13. <a class="loading-opts" href="playground.generated/index.html">[&lt;&lt; BACK]</a> <br/>
  14. THIS IS A GENERATED FILE VIA `npm run simpleserver`
  15. <div id="bar" style="margin-bottom: 6px;"></div>
  16. <div style="clear:both"></div>
  17. <div id="outer-container" style="width:800px;height:450px;border: 1px solid grey">
  18. <!-- ----------------------------------------SAMPLE HTML START-->
  19. <div id="container" style="height: 100%"></div>
  20. <!-- ----------------------------------------SAMPLE HTML END-->
  21. </div>
  22. <div style="clear:both"></div>
  23. <script src="../../metadata.js"></script>
  24. <script src="dev-setup.js"></script>
  25. <script>
  26. loadEditor(function() {
  27. /*----------------------------------------SAMPLE JS START*/
  28. var editor = monaco.editor.create(document.getElementById('container'), {
  29. value: '{\n\t"dependencies": {\n\t\t\n\t}\n}\n',
  30. language: 'json'
  31. });
  32. var commandId = editor.addCommand(
  33. 0,
  34. function () {
  35. // services available in `ctx`
  36. alert('my command is executing!');
  37. },
  38. ''
  39. );
  40. monaco.languages.registerCodeLensProvider('json', {
  41. provideCodeLenses: function (model, token) {
  42. return {
  43. lenses: [
  44. {
  45. range: {
  46. startLineNumber: 1,
  47. startColumn: 1,
  48. endLineNumber: 2,
  49. endColumn: 1
  50. },
  51. id: 'First Line',
  52. command: {
  53. id: commandId,
  54. title: 'First Line'
  55. }
  56. }
  57. ],
  58. dispose: () => {}
  59. };
  60. },
  61. resolveCodeLens: function (model, codeLens, token) {
  62. return codeLens;
  63. }
  64. });
  65. /*----------------------------------------SAMPLE JS END*/
  66. });
  67. </script>
  68. </body>
  69. </html>