Module: Katalyst::Content::EditorHelper
- Defined in:
- app/helpers/katalyst/content/editor_helper.rb
Instance Method Summary collapse
- #content_editor_container(container:, **options, &block) ⇒ Object
-
#content_editor_errors(container:, **options) ⇒ Object
Generate a turbo stream fragment that will show structural errors to the user.
- #content_editor_image_field(item:, method:, **options, &block) ⇒ Object
- #content_editor_item(item:, container: item.container, **options, &block) ⇒ Object
-
#content_editor_items(item:, container: item.container) ⇒ Object
Generate items without their list wrapper, similar to form_with/fields.
- #content_editor_list(container:, items: container.draft_items, **options) ⇒ Object
-
#content_editor_new_item(item:, container: item.container, **options, &block) ⇒ Object
Gene.
- #content_editor_new_items(container:) ⇒ Object
- #content_editor_rich_text_options(options = {}) ⇒ Object
- #content_editor_status_bar(container:, **options) ⇒ Object
-
#prefix_partial_path_with_controller_namespace ⇒ Object
When rendering item forms do not include the controller namespace prefix (katalyst/content).
Instance Method Details
#content_editor_container(container:, **options, &block) ⇒ Object
13 14 15 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 13 def content_editor_container(container:, **, &block) Editor::Container.new(self, container).build(, &block) end |
#content_editor_errors(container:, **options) ⇒ Object
Generate a turbo stream fragment that will show structural errors to the user.
29 30 31 32 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 29 def content_editor_errors(container:, **) turbo_stream.replace(dom_id(container, :errors), Editor::Errors.new(self, container).build(**)) end |
#content_editor_image_field(item:, method:, **options, &block) ⇒ Object
58 59 60 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 58 def content_editor_image_field(item:, method:, **, &block) Editor::ImageField.new(self, item.container).build(item, method, **, &block) end |
#content_editor_item(item:, container: item.container, **options, &block) ⇒ Object
39 40 41 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 39 def content_editor_item(item:, container: item.container, **, &block) Editor::Item.new(self, container).build(item, **, &block) end |
#content_editor_items(item:, container: item.container) ⇒ Object
Generate items without their list wrapper, similar to form_with/fields
24 25 26 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 24 def content_editor_items(item:, container: item.container) Editor::List.new(self, container).items(item) end |
#content_editor_list(container:, items: container.draft_items, **options) ⇒ Object
17 18 19 20 21 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 17 def content_editor_list(container:, items: container.draft_items, **) Editor::List.new(self, container).build() do |list| list.items(*items) if items.present? end end |
#content_editor_new_item(item:, container: item.container, **options, &block) ⇒ Object
Gene
35 36 37 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 35 def content_editor_new_item(item:, container: item.container, **, &block) Editor::NewItem.new(self, container).build(item, **, &block) end |
#content_editor_new_items(container:) ⇒ Object
6 7 8 9 10 11 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 6 def content_editor_new_items(container:) Katalyst::Content.config.items.map do |item_class| item_class = item_class.is_a?(String) ? item_class.safe_constantize : item_class item_class.new(container: container) end end |
#content_editor_rich_text_options(options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 47 def ( = {}) defaults = { data: { direct_upload_url: direct_uploads_url, controller: "content--editor--trix", action: "trix-initialize->content--editor--trix#trixInitialize", }, } defaults.deep_merge() end |
#content_editor_status_bar(container:, **options) ⇒ Object
43 44 45 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 43 def (container:, **) Editor::StatusBar.new(self, container).build(**) end |
#prefix_partial_path_with_controller_namespace ⇒ Object
When rendering item forms do not include the controller namespace prefix (katalyst/content)
63 64 65 |
# File 'app/helpers/katalyst/content/editor_helper.rb', line 63 def prefix_partial_path_with_controller_namespace false end |