sample.js 633 B

123456789101112131415161718192021222324252627282930313233
  1. var jsCode = [
  2. '"use strict";',
  3. 'function Person(age) {',
  4. ' if (age) {',
  5. ' this.age = age;',
  6. ' }',
  7. '}',
  8. 'Person.prototype.getAge = function () {',
  9. ' return this.age;',
  10. '};'
  11. ].join('\n');
  12. var editor = monaco.editor.create(document.getElementById('container'), {
  13. value: jsCode,
  14. language: 'javascript',
  15. glyphMargin: true
  16. });
  17. var decorations = editor.deltaDecorations(
  18. [],
  19. [
  20. {
  21. range: new monaco.Range(3, 1, 3, 1),
  22. options: {
  23. isWholeLine: true,
  24. className: 'myContentClass',
  25. glyphMarginClassName: 'myGlyphMarginClass'
  26. }
  27. }
  28. ]
  29. );
  30. // You can now use `decorations` to change or remove the decoration