Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

80 lines
2.3KB

  1. <template>
  2. <div>
  3. <div class="container" :id="name" :style="{'height': `calc(${height} - ( 8rem) )`}"></div>
  4. <div class="tags has-addons">
  5. <span class="tag"><label class="checkbox">
  6. <input type="checkbox" v-model="vim_mode">VIM</label>
  7. </span>
  8. <span class="tag is-primary" :id="`${name}_status`"></span>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import { initVimMode } from 'monaco-vim';
  14. export default {
  15. props: {
  16. vim_mode: {
  17. type: Boolean,
  18. required: true
  19. },
  20. name: {
  21. type: String,
  22. required: true
  23. },
  24. value: {
  25. type: String,
  26. required: false
  27. },
  28. language: {
  29. type: String,
  30. required: false
  31. },
  32. height: {
  33. type: String,
  34. required: true
  35. }
  36. },
  37. mounted() {
  38. this.editor = monaco.editor.create(document.getElementById(this.name), {
  39. value: this.value,
  40. language: this.language,
  41. automaticLayout: true
  42. });
  43. this.editor.onDidChangeModelContent(event => {
  44. const value = this.editor.getValue()
  45. if (this.value !== value) {
  46. this.$emit('input', value, event)
  47. }
  48. });
  49. this.vimMode_1 = initVimMode(this.editor, document.getElementById(this.name + "_status"))
  50. },
  51. watch: {
  52. value(new_val) {
  53. if (this.editor) {
  54. if (new_val !== this.editor.getValue()) {
  55. this.editor.setValue(new_val)
  56. this.$emit('input', new_val);
  57. }
  58. }
  59. },
  60. vim_mode(new_val) {
  61. if (new_val) {
  62. this.vimMode_1 = initVimMode(this.editor, document.getElementById(this.name + "_status"))
  63. } else {
  64. this.vimMode_1.dispose();
  65. document.getElementById(this.name + "_status").innerHTML = '';
  66. }
  67. }
  68. }
  69. }
  70. </script>
  71. <style scoped>
  72. .container {
  73. width: calc(50vw - ( 6rem) );
  74. }
  75. </style>