Sha256: 957eacb09ccc64fa70d82c20a8d447fecc8310b641cb3cae540e5c5aa7e33b5d

Contents?: true

Size: 772 Bytes

Versions: 139

Compression:

Stored size: 772 Bytes

Contents

import { Controller } from '@hotwired/stimulus'
import EasyMDE from 'easymde'

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

  get view() {
    return this.elementTarget.dataset.view
  }

  get componentOptions() {
    try {
      return JSON.parse(this.elementTarget.dataset.componentOptions)
    } catch (error) {
      return {}
    }
  }

  connect() {
    const options = {
      element: this.elementTarget,
      spellChecker: this.componentOptions.spell_checker,
      autoRefresh: { delay: 500},
    }

    if (this.view === 'show') {
      options.toolbar = false
      options.status = false
    }

    const easyMde = new EasyMDE(options)
    if (this.view === 'show') {
      easyMde.codemirror.options.readOnly = true
    }
  }
}

Version data entries

139 entries across 139 versions & 1 rubygems

Version Path
avo-3.0.1.beta19 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta24 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta15 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta16 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta14 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta12 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta13 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta10 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta11 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.0.pre19 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta8 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta9 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta6 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta7 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta5 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta2 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta4 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta3 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.0.beta1 app/javascript/js/controllers/fields/easy_mde_controller.js
avo-3.0.1.beta1 app/javascript/js/controllers/fields/easy_mde_controller.js