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.10.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.9.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.8.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.7.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.6.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.5.1 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.5.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.4.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.3.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.2.0 lib/draftjs_html/draftjs/content.rb
draftjs_html-0.1.0 lib/draftjs_html/draftjs/content.rb