Sha256: e693dd8d86750d4724e9824760088062115928fc816520846a295846237cc4f8

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

import 'codemirror/mode/css/css'

import 'codemirror/mode/dockerfile/dockerfile'
import 'codemirror/mode/htmlmixed/htmlmixed'
import 'codemirror/mode/javascript/javascript'
import 'codemirror/mode/markdown/markdown'
import 'codemirror/mode/nginx/nginx'
import 'codemirror/mode/php/php'
import 'codemirror/mode/ruby/ruby'
import 'codemirror/mode/sass/sass'
import 'codemirror/mode/shell/shell'
import 'codemirror/mode/sql/sql'
import 'codemirror/mode/vue/vue'
import 'codemirror/mode/xml/xml'

import { Controller } from 'stimulus'
import { castBoolean } from '@/js/helpers/cast_boolean'
import CodeMirror from 'codemirror'

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,
    }

    setTimeout(() => {
      CodeMirror.fromTextArea(this.elementTarget, options)
    }, 1)
  }
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
avo-1.3.4 app/packs/js/controllers/fields/code_field_controller.js
avo-1.3.3 app/packs/js/controllers/fields/code_field_controller.js
avo-1.3.2 app/packs/js/controllers/fields/code_field_controller.js
avo-1.3.1 app/packs/js/controllers/fields/code_field_controller.js
avo-1.3.0 app/packs/js/controllers/fields/code_field_controller.js
avo-1.2.11.pre.4 app/packs/js/controllers/fields/code_field_controller.js