aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
parente5cc70ea172c063ca53f6556216dc61eb420e371 (diff)
downloadrails-2bd0f608f268d6e98ad014ae6a2151e291ebce7c.tar.gz
rails-2bd0f608f268d6e98ad014ae6a2151e291ebce7c.tar.bz2
rails-2bd0f608f268d6e98ad014ae6a2151e291ebce7c.zip
Add support for "presentation" gallery attribute
Diffstat (limited to 'lib')
-rw-r--r--lib/action_text/attachment.rb2
-rw-r--r--lib/action_text/trix_attachment.rb7
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/action_text/attachment.rb b/lib/action_text/attachment.rb
index a0e0c2f396..cba421c143 100644
--- a/lib/action_text/attachment.rb
+++ b/lib/action_text/attachment.rb
@@ -4,7 +4,7 @@ module ActionText
TAG_NAME = "action-text-attachment"
SELECTOR = TAG_NAME
- ATTRIBUTES = %w( sgid content-type url href filename filesize width height previewable caption )
+ ATTRIBUTES = %w( sgid content-type url href filename filesize width height previewable presentation caption )
class << self
def fragment_by_canonicalizing_attachments(content)
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)