aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_text/trix_attachment.rb
diff options
context:
space:
mode:
authorJavan Makhmali <javan@javan.us>2018-10-03 12:11:39 -0400
committerJavan Makhmali <javan@javan.us>2018-10-03 12:11:39 -0400
commit2bd0f608f268d6e98ad014ae6a2151e291ebce7c (patch)
tree83340658463f9dd61e2ab5f3b128a1196a064d20 /lib/action_text/trix_attachment.rb
parente5cc70ea172c063ca53f6556216dc61eb420e371 (diff)
downloadrails-2bd0f608f268d6e98ad014ae6a2151e291ebce7c.tar.gz
rails-2bd0f608f268d6e98ad014ae6a2151e291ebce7c.tar.bz2
rails-2bd0f608f268d6e98ad014ae6a2151e291ebce7c.zip
Add support for "presentation" gallery attribute
Diffstat (limited to 'lib/action_text/trix_attachment.rb')
-rw-r--r--lib/action_text/trix_attachment.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/action_text/trix_attachment.rb b/lib/action_text/trix_attachment.rb
index 717d130d12..0c4a3869d8 100644
--- a/lib/action_text/trix_attachment.rb
+++ b/lib/action_text/trix_attachment.rb
@@ -3,7 +3,8 @@ module ActionText
TAG_NAME = "figure"
SELECTOR = "[data-trix-attachment]"
- ATTRIBUTES = %w( sgid contentType url href filename filesize width height previewable content caption )
+ COMPOSED_ATTRIBUTES = %w( caption presentation )
+ ATTRIBUTES = %w( sgid contentType url href filename filesize width height previewable content ) + COMPOSED_ATTRIBUTES
ATTRIBUTE_TYPES = {
"previewable" => ->(value) { value.to_s == "true" },
"filesize" => ->(value) { Integer(value.to_s) rescue value },
@@ -16,8 +17,8 @@ module ActionText
def from_attributes(attributes)
attributes = process_attributes(attributes)
- trix_attachment_attributes = attributes.except("caption")
- trix_attributes = attributes.slice("caption")
+ trix_attachment_attributes = attributes.except(*COMPOSED_ATTRIBUTES)
+ trix_attributes = attributes.slice(*COMPOSED_ATTRIBUTES)
node = ActionText::HtmlConversion.create_element(TAG_NAME)
node["data-trix-attachment"] = JSON.generate(trix_attachment_attributes)