Class: Practical::Views::TiptapDocumentComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Practical::Views::TiptapDocumentComponent
- 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
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(document:) ⇒ TiptapDocumentComponent
constructor
A new instance of TiptapDocumentComponent.
Methods included from NodeRendering
Methods included from ElementHelper
Constructor Details
#initialize(document:) ⇒ TiptapDocumentComponent
Returns a new instance of TiptapDocumentComponent.
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
#document ⇒ Object (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
#call ⇒ Object
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 |