Class: Practical::Views::TiptapDocumentComponent::Heading

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

Instance Attribute Summary

Attributes inherited from Node

#node_content

Instance Method Summary collapse

Methods inherited from Node

#initialize, #render_node_contents

Methods included from NodeRendering

#render_node

Methods included from ElementHelper

#grab, #mix

Constructor Details

This class inherits a constructor from Practical::Views::TiptapDocumentComponent::Node

Instance Method Details

#callObject



126
127
128
129
130
# File 'app/components/practical/views/tiptap_document_component.rb', line 126

def call
  heading_element {
    render_node_contents
  }
end

#heading_element(&block) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'app/components/practical/views/tiptap_document_component.rb', line 132

def heading_element(&block)
  case node_content.dig(:attrs, :level)
  when 1
    tag.h1(&block)
  when 2
    tag.h2(&block)
  when 3
    tag.h3(&block)
  when 4
    tag.h4(&block)
  when 5
    tag.h5(&block)
  when 6
    tag.h6(&block)
  end
end