Class: Prosemirror

Inherits:
Object
  • Object
show all
Defined in:
app/models/prosemirror.rb

Instance Method Summary collapse

Instance Method Details

#format_content(parsed_content) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'app/models/prosemirror.rb', line 10

def format_content(parsed_content)
  return if parsed_content.blank?

  content = renderer.render(parsed_content)
  content = ProsemirrorToHtml::RemoveEmptyParagraphsFormatter.new(content).to_s
  content = ProsemirrorToHtml::GlobalIdToLinksFormatter.new(content).to_s
  # rubocop:disable Rails/OutputSafety
  content.html_safe
  # rubocop:enable Rails/OutputSafety
end

#rendererObject



2
3
4
5
6
7
8
# File 'app/models/prosemirror.rb', line 2

def renderer
  return @renderer if @renderer

  @renderer = ProsemirrorToHtml::Renderer.new
  @renderer.add_node(ProsemirrorToHtml::Nodes::ImageBlock)
  @renderer.add_node(ProsemirrorToHtml::Nodes::PromptsBlock)
end