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.



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

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.



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

def block_map
  @block_map
end

#entity_decoratorsObject (readonly)

Returns the value of attribute entity_decorators.



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

def entity_decorators
  @entity_decorators
end

#style_mapObject (readonly)

Returns the value of attribute style_map.



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

def style_map
  @style_map
end

Instance Method Details

#call(content_state) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/draftjs_exporter/html.rb', line 18

def call(content_state)
  wrapper_state = WrapperState.new(block_map)
  content_state.fetch(:blocks, []).each do |block|
    element = wrapper_state.element_for(block)
    entity_map = content_state.fetch(:entityMap, {})
    block_contents(element, block, entity_map)
  end
  wrapper_state.to_s
end