Class: Panda::CMS::RichTextComponent
- Inherits:
-
Panda::Core::Base
- Object
- Panda::Core::Base
- Panda::CMS::RichTextComponent
- Defined in:
- app/components/panda/cms/rich_text_component.rb
Overview
Rich text component for EditorJS-based content editing
Defined Under Namespace
Classes: ComponentError
Constant Summary collapse
- KIND =
"rich_text"
Instance Attribute Summary collapse
-
#block_content_id ⇒ Object
Returns the value of attribute block_content_id.
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
Instance Attribute Details
#block_content_id ⇒ Object
Returns the value of attribute block_content_id.
18 19 20 |
# File 'app/components/panda/cms/rich_text_component.rb', line 18 def block_content_id @block_content_id end |
#content ⇒ Object
Returns the value of attribute content.
18 19 20 |
# File 'app/components/panda/cms/rich_text_component.rb', line 18 def content @content end |
Instance Method Details
#before_template ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/components/panda/cms/rich_text_component.rb', line 40 def before_template setup_editability load_block_content prepare_content rescue ActiveRecord::RecordNotFound => e handle_error(ComponentError.new("Database record not found: #{e.}")) rescue ActiveRecord::RecordInvalid => e handle_error(ComponentError.new("Invalid record: #{e.}")) rescue => e handle_error(e) end |
#render_content ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'app/components/panda/cms/rich_text_component.rb', line 30 def render_content div(class: "panda-cms-content", **element_attrs) do if @editable_state # Empty div for EditorJS to initialize into else raw(@rendered_content.html_safe) end end end |
#view_template ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/components/panda/cms/rich_text_component.rb', line 20 def view_template # Russian doll caching: Cache component output at block_content level # Only cache in non-editable mode (public-facing pages) if should_cache? raw cache_component_output else render_content end end |