Class: TinyMCE::Rails::Configuration
- Inherits:
-
Object
- Object
- TinyMCE::Rails::Configuration
- Defined in:
- lib/tinymce/rails/configuration.rb
Defined Under Namespace
Classes: Function
Constant Summary collapse
- FUNCTION_REGEX =
/^function\s*\(/
- RELATIVE_PATH_REGEX =
/^(\/|\.{1,2})\S*/
- COMMA =
",".freeze
- SPACE =
" ".freeze
- SEMICOLON =
";".freeze
- OPTION_SEPARATORS =
{ "plugins" => COMMA, "custom_elements" => COMMA, "entities" => COMMA, "extended_valid_elements" => COMMA, "font_formats" => SEMICOLON, "fontsize_formats" => COMMA, "invalid_elements" => COMMA, "block_formats" => SEMICOLON, "valid_children" => COMMA, "valid_elements" => COMMA, "body_id" => COMMA, "body_class" => COMMA, "content_css" => COMMA, "tabfocus_elements" => COMMA, "table_clone_elements" => SPACE, "paste_word_valid_elements" => COMMA, "paste_webkit_styles" => SPACE, "paste_retain_style_properties" => SPACE, "spellchecker_languages" => COMMA }
- OPTION_TRANSFORMERS =
{ # Check for files provided in the content_css option to replace them with their actual path. # If no corresponding stylesheet is found for a file, it will remain unchanged. "content_css" => ->(value) { helpers = ActionView::Base.new(ActionView::LookupContext.new([])) separator = OPTION_SEPARATORS["content_css"] value.split(separator).map { |file| next file if RELATIVE_PATH_REGEX =~ file helpers.stylesheet_path(file.strip) || file }.join(separator) } }
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Configuration
constructor
A new instance of Configuration.
- #merge(options) ⇒ Object
-
#options_for_tinymce ⇒ Object
Converts options into a TinyMCE-friendly format.
-
#to_javascript ⇒ Object
Converts options into a String representing a JavaScript object that can be passed directly to tinyMCE.init.
Constructor Details
#initialize(options) ⇒ Configuration
Returns a new instance of Configuration.
63 64 65 |
# File 'lib/tinymce/rails/configuration.rb', line 63 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
61 62 63 |
# File 'lib/tinymce/rails/configuration.rb', line 61 def @options end |
Class Method Details
.defaults ⇒ Object
11 12 13 14 15 16 |
# File 'lib/tinymce/rails/configuration.rb', line 11 def self.defaults { "selector" => "textarea.tinymce", "cache_suffix" => "?v=#{VERSION}" } end |
.new_with_defaults(options = {}) ⇒ Object
67 68 69 70 71 |
# File 'lib/tinymce/rails/configuration.rb', line 67 def self.new_with_defaults(={}) config = new(defaults) config = config.merge() if config end |
Instance Method Details
#merge(options) ⇒ Object
88 89 90 |
# File 'lib/tinymce/rails/configuration.rb', line 88 def merge() self.class.new(self..merge()) end |
#options_for_tinymce ⇒ Object
Converts options into a TinyMCE-friendly format.
1. Joins array values using OPTION_SEPARATORS
2. Converts JavaScript function() strings to Function objects
3. Applies transformations from OPTION_TRANSFORMERS
84 85 86 |
# File 'lib/tinymce/rails/configuration.rb', line 84 def () end |
#to_javascript ⇒ Object
Converts options into a String representing a JavaScript object that can be passed directly to tinyMCE.init
75 76 77 |
# File 'lib/tinymce/rails/configuration.rb', line 75 def to_javascript () end |