Class: Prosemirror
- Inherits:
-
Object
- Object
- Prosemirror
- 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 20 21 22 |
# File 'app/models/prosemirror.rb', line 10 def format_content(parsed_content) return if parsed_content.blank? # GlobalIDs must be resolved to URLs before rendering: the renderer's # sanitizer strips href attributes with unknown protocols, so a gid:// # link would lose its href entirely. content = ProsemirrorToHtml::GlobalIdToLinksFormatter.new(parsed_content.to_json).to_s content = renderer.render(JSON.parse(content)) content = ProsemirrorToHtml::RemoveEmptyParagraphsFormatter.new(content).to_s # rubocop:disable Rails/OutputSafety content.html_safe # rubocop:enable Rails/OutputSafety end |
#renderer ⇒ Object
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 |