Sha256: e420568cdb2c8f5e5ee76199efc1411ce7f45c0c95c6b94c114f6d8bab6d0f8e

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

module RenderEditorjs
  # Built in renderer with healthy defaults
  class DefaultRenderer
    SCHEMA = YAML.safe_load(<<~YAML)
      type: object
      additionalProperties: false
      properties:
        time:
          type: number
        blocks:
          type: array
          items:
            type: object
        version:
          type: string
      required:
      - time
      - blocks
      - version
    YAML

    DEFAULT_MAPPING = {
      "paragraph" => RenderEditorjs::Blocks::Paragraph.new,
      "header" => RenderEditorjs::Blocks::Header.new,
      "list" => RenderEditorjs::Blocks::List.new,
      "image" => RenderEditorjs::Blocks::Image.new
    }.freeze

    attr_reader :mapping

    def initialize(custom_mapping = {})
      @mapping = DEFAULT_MAPPING.merge(custom_mapping)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
render_editorjs-0.1.0 lib/render_editorjs/default_renderer.rb