Module: EffectiveEditorHelper

Defined in:
app/helpers/effective_editor_helper.rb

Instance Method Summary collapse

Instance Method Details

#effective_editor_tag(content, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/effective_editor_helper.rb', line 5

def effective_editor_tag(content, options = {})
  content = content.presence || '{}'

  content_mode = (
    if options.delete(:delta)
      :delta
    elsif options.delete(:html)
      :html
    elsif options.delete(:code)
      :code
    else
      :delta
    end
  )

  input_js = {
    method_name: 'effective_editor_tag',
    theme: 'snow',
    readOnly: true,
    content_mode: content_mode,
    modules: { toolbar: false, syntax: (content_mode == :code) }
  }

  (:div, '', id: "ql-#{content.object_id}", class: 'effective_editor_content ql-effective', data: { 'input-js-options': input_js, 'content': content })
end