class EditorJs::Blocks::ParagraphBlock
paragraph block
Public Instance Methods
plain()
click to toggle source
# File lib/editor_js/blocks/paragraph_block.rb, line 56 def plain decode_html(Sanitize.fragment data['text']).strip end
render(_options = {})
click to toggle source
# File lib/editor_js/blocks/paragraph_block.rb, line 23 def render(_options = {}) alignment = data['alignment'] class_name_str = css_name if alignment.present? class_name_str = [ class_name_str, css_name("__#{alignment}") ].join(' ') end content_tag(:div, class: class_name_str) { data['text'].html_safe } end
sanitize!()
click to toggle source
# File lib/editor_js/blocks/paragraph_block.rb, line 47 def sanitize! data['text'] = Sanitize.fragment( data['text'], elements: safe_tags.keys, attributes: safe_tags.select { |_k, v| v }, remove_contents: true ) end
schema()
click to toggle source
# File lib/editor_js/blocks/paragraph_block.rb, line 7 def schema YAML.safe_load(<<~YAML) type: object additionalProperties: false properties: text: type: string alignment: type: string enum: - align-left - align-center - align-right YAML end