Sha256: 49f622607ebd8e5c5416e1aacd047aed7b908e85322756be6e5de580b818d8b1
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true module EditorJs module Blocks class HeaderBlock < Base def schema YAML.safe_load(<<~YAML) type: object additionalProperties: false properties: text: type: string level: type: number enum: [1,2,3,4,5,6] alignment: type: string enum: - align-left - align-center - align-right required: - text - level YAML end 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(:"h#{data['level']}", data['text'].html_safe, class: class_name_str) end def sanitize! data['text'] = Sanitize.fragment(data['text'], remove_contents: true).strip end def plain decode_html data['text'].strip end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
editor_js-0.3.3 | lib/editor_js/blocks/header_block.rb |