Class: Fields::RichTextArea

Inherits:
Field
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
app/models/iron/fields/rich_text_area.rb

Instance Method Summary collapse

Instance Method Details

#content_value=(value) ⇒ Object



7
8
9
# File 'app/models/iron/fields/rich_text_area.rb', line 7

def content_value=(value)
  self.rich_text = value
end

#export_attachmentsObject



29
30
31
32
33
34
35
# File 'app/models/iron/fields/rich_text_area.rb', line 29

def export_attachments
  return [] unless rich_text&.body.present?

  rich_text.body.attachables.filter_map do |attachable|
    attachable.blob if attachable.respond_to?(:blob)
  end
end

#export_valueObject



19
20
21
22
23
24
25
26
27
# File 'app/models/iron/fields/rich_text_area.rb', line 19

def export_value
  return { type: "rich_text_area", value: nil } unless rich_text&.body.present?

  html = rich_text.body.render_attachments do |attachment|
    export_attachment_tag(attachment)
  end.to_html

  { type: "rich_text_area", value: html }
end

#searchable_textObject



11
12
13
# File 'app/models/iron/fields/rich_text_area.rb', line 11

def searchable_text
  rich_text&.to_plain_text
end

#valueObject



15
16
17
# File 'app/models/iron/fields/rich_text_area.rb', line 15

def value
  rich_text&.to_s
end