class RenderEditorjs::Blocks::Paragraph
Compatible with default Paragraph
and paragraph-with-aligment github.com/kaaaaaaaaaaai/paragraph-with-alignment
Constants
- DEFAULT_OPTIONS
- DEFAULT_SAFE_TAGS
- SCHEMA
Attributes
options[R]
Public Class Methods
new(options = DEFAULT_OPTIONS.dup)
click to toggle source
Calls superclass method
# File lib/render_editorjs/blocks/paragraph.rb, line 38 def initialize(options = DEFAULT_OPTIONS.dup) @options = options @options[:safe_tags] ||= DEFAULT_SAFE_TAGS super() end
Public Instance Methods
render(data)
click to toggle source
# File lib/render_editorjs/blocks/paragraph.rb, line 44 def render(data) return unless valid?(data) alignment = data["alignment"] css_class = alignment ? "align-#{alignment}" : nil content_tag(options[:tag], class: css_class) do sanitize(data["text"]).html_safe end end
sanitize(text)
click to toggle source
# File lib/render_editorjs/blocks/paragraph.rb, line 54 def sanitize(text) Sanitize.fragment( text, elements: options[:safe_tags].keys, attributes: options[:safe_tags].select { |_k, v| v }, remove_contents: true ) end