Sha256: 26aad8cb36c55475960bda2763cc2ee6accf22bf3441e4ec0037945f6af98a54

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

import { Controller } from 'stimulus'
import { castBoolean } from '@/js/helpers/cast_boolean'
import CodeMirror from 'codemirror'
import 'codemirror/mode/css/css.js'
import 'codemirror/mode/css/css.js'
import 'codemirror/mode/dockerfile/dockerfile.js'
import 'codemirror/mode/htmlmixed/htmlmixed.js'
import 'codemirror/mode/javascript/javascript.js'
import 'codemirror/mode/markdown/markdown.js'
import 'codemirror/mode/nginx/nginx.js'
import 'codemirror/mode/php/php.js'
import 'codemirror/mode/ruby/ruby.js'
import 'codemirror/mode/sass/sass.js'
import 'codemirror/mode/shell/shell.js'
import 'codemirror/mode/sql/sql.js'
import 'codemirror/mode/vue/vue.js'
import 'codemirror/mode/xml/xml.js'

export default class extends Controller {
  static targets = ['element']

  connect() {
    const options = {
      readOnly: castBoolean(this.elementTarget.dataset.readOnly),
      mode: this.elementTarget.dataset.language,
      theme: this.elementTarget.dataset.theme,
      tabSize: this.elementTarget.dataset.tabSize,
      indentWithTabs: castBoolean(this.elementTarget.dataset.indentWithTabs),
      lineWrapping: castBoolean(this.elementTarget.dataset.lineWrapping),
      lineNumbers: true,
    }

    CodeMirror.fromTextArea(this.elementTarget, options)
  }
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
avo-0.5.0.beta9 app/packs/js/controllers/fields/code_field_controller.js
avo-0.5.0.beta8 app/packs/js/controllers/fields/code_field_controller.js
avo-0.5.0.beta7 app/frontend/js/controllers/fields/code_field_controller.js
avo-0.5.0.beta6 app/frontend/js/controllers/fields/code_field_controller.js
avo-0.5.0.beta5 app/frontend/js/controllers/fields/code_field_controller.js
avo-0.5.0.beta4 app/frontend/js/controllers/fields/code_field_controller.js
avo-0.5.0.beta3 app/frontend/js/controllers/fields/code_field_controller.js
avo-0.5.0.beta2 app/frontend/js/controllers/fields/code_field_controller.js
avo-0.5.0.beta1 app/frontend/js/controllers/fields/code_field_controller.js