Class: Practical::Views::TiptapDocumentComponent

Inherits:
BaseComponent
  • Object
show all
Includes:
NodeRendering
Defined in:
app/components/practical/views/tiptap_document_component.rb

Defined Under Namespace

Modules: NodeRendering Classes: Attachment, Blockquote, CodeBlock, HardBreak, Heading, ListItem, Node, OrderedList, Paragraph, Text, UnknownMarkupTypeError, UnknownNodeTypeError, UnorderedList

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NodeRendering

#render_node

Methods included from ElementHelper

#grab, #mix

Constructor Details

#initialize(document:) ⇒ TiptapDocumentComponent

Returns a new instance of TiptapDocumentComponent.

Raises:

  • (ArgumentError)


40
41
42
43
# File 'app/components/practical/views/tiptap_document_component.rb', line 40

def initialize(document:)
  raise ArgumentError if document["type"] != "doc"
  @document = document.with_indifferent_access
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



38
39
40
# File 'app/components/practical/views/tiptap_document_component.rb', line 38

def document
  @document
end

Instance Method Details

#callObject



45
46
47
48
49
# File 'app/components/practical/views/tiptap_document_component.rb', line 45

def call
  safe_join([document[:content].map do |node|
    render_node(node: node)
  end])
end