Sha256: afab3ba27753468ca54068109fc6c4ae9aaa6f7ef28d42fac5df9ac9c7d8cfc0
Contents?: true
Size: 1.34 KB
Versions: 19
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true module Alchemy module Ingredients # A blob of richtext # class Richtext < Alchemy::Ingredient store_accessor :data, :stripped_body, :sanitized_body allow_settings %i[ plain_text sanitizer tinymce ] before_save :strip_content before_save :sanitize_content # The first 30 characters of the stripped_body # # Used by the Element#preview_text method. # # @param [Integer] max_length (30) # def preview_text(max_length = 30) stripped_body.to_s[0..max_length - 1] end def element_id "tinymce_#{id}" end def has_tinymce? true end # Returns true if there is a tinymce setting defined that contains settings. def has_custom_tinymce_config? custom_tinymce_config.is_a?(Hash) end def custom_tinymce_config settings[:tinymce] end private def strip_content self.stripped_body = Rails::Html::FullSanitizer.new.sanitize(value) end def sanitize_content self.sanitized_body = Rails::Html::SafeListSanitizer.new.sanitize( value, sanitizer_settings ) end def sanitizer_settings settings[:sanitizer] || {} end end end end
Version data entries
19 entries across 19 versions & 1 rubygems