class EditorJs::Blocks::ChecklistBlock
checklist block
Public Instance Methods
plain()
click to toggle source
# File lib/editor_js/blocks/checklist_block.rb, line 62 def plain data['items'].map { |item| decode_html(item['text']).strip }.join(', ') end
render(_options = {})
click to toggle source
# File lib/editor_js/blocks/checklist_block.rb, line 27 def render(_options = {}) content_tag :div, class: css_name do data['items'].map do |item| content_tag(:div, class: css_name('__warrper')) do html_str = content_tag(:input, nil, type: 'checkbox', disabled: true, checked: item['checked']) html_str += content_tag(:label, item['text'].html_safe) html_str.html_safe end.html_safe end.join.html_safe end end
sanitize!()
click to toggle source
# File lib/editor_js/blocks/checklist_block.rb, line 51 def sanitize! data['items'].each do |item| item['text'] = Sanitize.fragment( item['text'], elements: safe_tags.keys, attributes: safe_tags.select { |_k, v| v }, remove_contents: true ) end end
schema()
click to toggle source
# File lib/editor_js/blocks/checklist_block.rb, line 7 def schema YAML.safe_load(<<~YAML) type: object additionalProperties: false properties: items: type: array items: type: object additionalProperties: false properties: text: type: string checked: type: boolean required: - text YAML end