Class: DraftjsExporter::HTML

Inherits:
Object
  • Object
show all
Defined in:
lib/draftjs_exporter/html.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block_map:, style_map:, entity_decorators:) ⇒ HTML

Returns a new instance of HTML.



11
12
13
14
15
# File 'lib/draftjs_exporter/html.rb', line 11

def initialize(block_map:, style_map:, entity_decorators:)
  @block_map = block_map
  @style_map = style_map
  @entity_decorators = entity_decorators
end

Instance Attribute Details

#block_mapObject (readonly)

Returns the value of attribute block_map.



9
10
11
# File 'lib/draftjs_exporter/html.rb', line 9

def block_map
  @block_map
end

#entity_decoratorsObject (readonly)

Returns the value of attribute entity_decorators.



9
10
11
# File 'lib/draftjs_exporter/html.rb', line 9

def entity_decorators
  @entity_decorators
end

#style_mapObject (readonly)

Returns the value of attribute style_map.



9
10
11
# File 'lib/draftjs_exporter/html.rb', line 9

def style_map
  @style_map
end

Instance Method Details

#call(content_state) ⇒ Object



17
18
19
20
21
# File 'lib/draftjs_exporter/html.rb', line 17

def call(content_state)
  content_state.fetch(:blocks, []).map { |block|
    content_state_block(block, content_state.fetch(:entityMap, {}))
  }.inject(:+)
end