Sha256: 135b88f4715de36f64eef3d2fc0bd25a7da3937767769d9d104b612eed987f92

Contents?: true

Size: 499 Bytes

Versions: 31

Compression:

Stored size: 499 Bytes

Contents

# frozen_string_literal: true

module DraftjsHtml
  module Draftjs
    class Content
      def self.parse(raw)
        new(raw['blocks'].map { Block.parse(**_1) }, EntityMap.parse(raw['entityMap']))
      end

      attr_reader :blocks, :entity_map

      def initialize(blocks, entity_map)
        @blocks = blocks
        @entity_map = entity_map
      end

      def find_entity(key)
        entity_map[key]
      end

      def to_raw
        ToRaw.new.convert(self)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
draftjs_html-0.30.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.29.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.28.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.27.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.26.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.25.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.24.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.23.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.22.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.21.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.20.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.19.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.18.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.17.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.16.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.15.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.14.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.13.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.12.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.11.0 lib/draftjs_html/draftjs/content.rb