Sha256: 4367b46372723ff482aac50144b5308f8cc25a44c3a36cfeea0d4ba64e812597
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true module EditorJs module Blocks class EmbedBlock < Base def schema YAML.safe_load(<<~YAML) type: object additionalProperties: false properties: caption: type: string embed: type: string height: type: string service: type: string source: type: string width: type: string required: - embed - service - source - width - height YAML end def render(options = {}) content_tag :div, class: css_name do concat content_tag(:iframe, '', src: data['embed'], width: data['width'], height: data['height'], frameborder: options.fetch('frameborder', '0'), allowfullscreen: options.fetch('allowfullscreen', true)) concat content_tag(:span, data['caption']) end end def sanitize! %w[caption embed height service source width].each do |key| str = Sanitize.fragment(data[key], remove_contents: true).strip if %w[embed service source].include?(key) str.gsub('&', '&') end data[key] = str end end def plain data['caption'].strip end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
editor_js-0.2.3 | lib/editor_js/blocks/embed_block.rb |