Module: Katalyst::Content::EditorHelper

Defined in:
app/helpers/katalyst/content/editor_helper.rb

Instance Method Summary collapse

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:, **options, &block)
  Editor::Container.new(self, container).build(options, &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:, **options)
  turbo_stream.replace(dom_id(container, :errors),
                       Editor::Errors.new(self, container).build(**options))
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:, **options, &block)
  Editor::ImageField.new(self, item.container).build(item, method, **options, &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, **options, &block)
  Editor::Item.new(self, container).build(item, **options, &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, **options)
  Editor::List.new(self, container).build(options) 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, **options, &block)
  Editor::NewItem.new(self, container).build(item, **options, &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 content_editor_rich_text_options(options = {})
  defaults = {
    data: {
      direct_upload_url: direct_uploads_url,
      controller:        "content--editor--trix",
      action:            "trix-initialize->content--editor--trix#trixInitialize",
    },
  }
  defaults.deep_merge(options)
end

#content_editor_status_bar(container:, **options) ⇒ Object



43
44
45
# File 'app/helpers/katalyst/content/editor_helper.rb', line 43

def content_editor_status_bar(container:, **options)
  Editor::StatusBar.new(self, container).build(**options)
end

#prefix_partial_path_with_controller_namespaceObject

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