Sha256: f40338b56ae7123329edb796e0e6c144e8fabc4af6a866b825a3ab20bee8be49
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module EditorJs module Blocks class ChecklistBlock < Base 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 def render(_options = {}) content_tag :div, class: css_name do data['items'].each do |item| concat content_tag(:input, item['text'], type: 'checkbox', disabled: true, checked: item['checked']) end end end def sanitize! data['items'].each do |item| item['text'] = Sanitize.fragment(item['text'], remove_contents: true).strip end end def plain data['items'].map { |item| decode_html(item['text']).strip }.join(', ') end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
editor_js-0.2.1 | lib/editor_js/blocks/checklist_block.rb |
editor_js-0.2.0 | lib/editor_js/blocks/checklist_block.rb |
editor_js-0.1.0 | lib/editor_js/blocks/checklist_block.rb |