Class: MorriganEditorRails::Editor

Inherits:
Object
  • Object
show all
Defined in:
lib/morrigan_editor_rails.rb

Constant Summary collapse

WHITELIST_CLASSES =
['mrge-content-block', 'mrge-left-side', 'mrge-content-block-item']
WHITELIST_ELEMENTS =
['a', 'p', 'h2', 'h3', 'h4', 'strong', 'em', 'strike', 'img', 'iframe', 'ol', 'ul', 'li', 'div']

Class Method Summary collapse

Class Method Details

.sanitize(html) ⇒ Object



12
13
14
# File 'lib/morrigan_editor_rails.rb', line 12

def self.sanitize(html)
  Sanitize.fragment html, self.sanitize_config
end

.sanitize_configObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/morrigan_editor_rails.rb', line 16

def self.sanitize_config
  {
      :elements => WHITELIST_ELEMENTS,

      :attributes => {
          'a' => ['href'],
          'p' => ['style'],
          'img' => ['src', 'style'],
          'iframe' => ['width', 'height', 'src', 'frameborder', 'allowfullscreen', 'wmode', 'style'],
          'div' => ['style', 'contenteditable', 'class'],
          'h2' => ['style'],
          'h3' => ['style'],
          'h4' => ['style']
      },

      :css => {
          :properties => ['max-width', 'max-height', 'width', 'height', 'font-size', 'font-weight', 'color', 'font-family', 'text-align']
      },

      :protocols => {
          'a' => {'href' => ['http', 'https', 'mailto', 'ftp']}
      }
  }
end