Module: RicherText::TagHelper

Defined in:
lib/richer_text/tag_helper.rb,
app/helpers/richer_text/tag_helper.rb

Instance Method Summary collapse

Instance Method Details

#rhino_text_area_tag(name, value = nil, options = {}) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
# File 'app/helpers/richer_text/tag_helper.rb', line 77

def rhino_text_area_tag(name, value = nil, options = {})
  options = options.symbolize_keys
  options[:input] ||= "rhino_text_input_#{RicherText::TagHelper.id += 1}"

  # So we can choose the serializer to use, e.g. "html" or "json"
  options[:serializer] ||= "html"

  input_tag = hidden_field_tag(name, value, id: options[:input])
  editor_tag = tag("rhino-editor", { input: options[:input], serializer: "json",  data: { "blob-url-template": rails_service_blob_url(":signed_id", ":filename"), "direct-upload-url": rails_direct_uploads_url }}.merge(options))

  input_tag + editor_tag
end

#richer_text_area_tag(name, value = nil, options = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/helpers/richer_text/tag_helper.rb', line 61

def richer_text_area_tag(name, value = nil, options = {})
  options = RicherText.default_form_options.merge(options.symbolize_keys).symbolize_keys
  options[:input] ||= "richer_text_input_#{RicherText::TagHelper.id += 1}"

  # So that we can access the content in the tiptap editor
  options[:content] ||= value

  # So we can choose the serializer to use, e.g. "html" or "json"
  options[:serializer] ||= "html"

  input_tag = hidden_field_tag(name, value, id: options[:input])
  editor_tag = tag("richer-text-editor", options)

  input_tag + editor_tag
end