Class: Forms::RichTextarea

Inherits:
Phlex::HTML
  • Object
show all
Defined in:
lib/forms/rich_textarea.rb

Overview

A rich-text editor backed by the Lexxy <lexxy-editor> custom element for ActionText. Optional feature: requires ActionText/Lexxy in the host app. Renders an editor bound to the field; when the value is an ActionText::RichText its HTML body is used as the initial content.

Instance Method Summary collapse

Constructor Details

#initialize(*modifiers, name:, id: nil, value: nil, **options) ⇒ RichTextarea

Returns a new instance of RichTextarea.



11
12
13
14
15
16
17
18
# File 'lib/forms/rich_textarea.rb', line 11

def initialize(*modifiers, name:, id: nil, value: nil, **options)
  @modifiers = modifiers
  @name = name
  @id = id || name.to_s.gsub(/[\[\]]/, "_").gsub(/_+$/, "")
  @value = value
  @options = options
  super()
end

Instance Method Details

#view_templateObject



20
21
22
23
24
25
26
27
28
# File 'lib/forms/rich_textarea.rb', line 20

def view_template
  lexxy_editor(
    name: @name,
    id: @id,
    value: formatted_value,
    class: editor_classes,
    **@options.except(:class, :error)
  )
end