Sha256: f614b0b6047de948bc09be34cef343715b87beb3fa608b3b5f9dbb32380a6fdf
Contents?: true
Size: 948 Bytes
Versions: 5
Compression:
Stored size: 948 Bytes
Contents
# frozen_string_literal: true module RenderEditorjs module Blocks # Compatible with https://github.com/editor-js/header class Header < Base 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: - left - center - right required: - text - level YAML def render(data) return unless valid?(data) alignment = data["alignment"] css_class = alignment ? "align-#{alignment}" : nil content_tag(:"h#{data["level"]}", sanitize(data["text"]).html_safe, class: css_class) end def sanitize(text) Sanitize.fragment(text, remove_contents: true).strip end end end end
Version data entries
5 entries across 5 versions & 1 rubygems