Sha256: 56edf06ca28d97b6ac01aab4c649dc230652278c0337253a832de6e8d90d519e

Contents?: true

Size: 752 Bytes

Versions: 10

Compression:

Stored size: 752 Bytes

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]
          required:
          - text
          - level
        YAML
      end

      def render(_options = {})
        content_tag(:"h#{data['level']}", data['text'].html_safe, class: css_name)
      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

10 entries across 10 versions & 1 rubygems

Version Path
editor_js-0.3.2 lib/editor_js/blocks/header_block.rb
editor_js-0.3.1 lib/editor_js/blocks/header_block.rb
editor_js-0.3.0 lib/editor_js/blocks/header_block.rb
editor_js-0.2.5 lib/editor_js/blocks/header_block.rb
editor_js-0.2.4 lib/editor_js/blocks/header_block.rb
editor_js-0.2.3 lib/editor_js/blocks/header_block.rb
editor_js-0.2.2 lib/editor_js/blocks/header_block.rb
editor_js-0.2.1 lib/editor_js/blocks/header_block.rb
editor_js-0.2.0 lib/editor_js/blocks/header_block.rb
editor_js-0.1.0 lib/editor_js/blocks/header_block.rb