katalyst-content 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +81 -7
  3. data/app/assets/builds/katalyst/content.esm.js +1004 -0
  4. data/app/assets/builds/katalyst/content.js +1004 -0
  5. data/app/assets/builds/katalyst/content.min.js +2 -0
  6. data/app/assets/builds/katalyst/content.min.js.map +1 -0
  7. data/app/assets/config/katalyst-content.js +1 -1
  8. data/app/assets/stylesheets/katalyst/content/editor/_index.scss +1 -1
  9. data/app/assets/stylesheets/katalyst/content/editor/_new-items.scss +36 -10
  10. data/app/assets/stylesheets/katalyst/content/editor/_status-bar.scss +3 -1
  11. data/app/{helpers/katalyst/content/editor/base.rb → components/katalyst/content/editor/base_component.rb} +15 -12
  12. data/app/components/katalyst/content/editor/errors_component.html.erb +12 -0
  13. data/app/components/katalyst/content/editor/errors_component.rb +15 -0
  14. data/app/components/katalyst/content/editor/item_component.html.erb +25 -0
  15. data/app/components/katalyst/content/editor/item_component.rb +28 -0
  16. data/app/components/katalyst/content/editor/new_item_component.html.erb +22 -0
  17. data/app/components/katalyst/content/editor/new_item_component.rb +52 -0
  18. data/app/{views/katalyst/content/editor/_new_items.html.erb → components/katalyst/content/editor/new_items_component.html.erb} +1 -1
  19. data/app/components/katalyst/content/editor/new_items_component.rb +20 -0
  20. data/app/{views/katalyst/content/editor/_list_item.html.erb → components/katalyst/content/editor/row_component.html.erb} +1 -1
  21. data/app/components/katalyst/content/editor/row_component.rb +13 -0
  22. data/app/{helpers/katalyst/content/editor/status_bar.rb → components/katalyst/content/editor/status_bar_component.rb} +17 -13
  23. data/app/components/katalyst/content/editor/table_component.html.erb +11 -0
  24. data/app/components/katalyst/content/editor/table_component.rb +36 -0
  25. data/app/components/katalyst/content/editor_component.html.erb +9 -0
  26. data/app/components/katalyst/content/editor_component.rb +49 -0
  27. data/app/controllers/katalyst/content/items_controller.rb +6 -3
  28. data/app/helpers/katalyst/content/editor_helper.rb +4 -48
  29. data/app/helpers/katalyst/content/frontend_helper.rb +5 -5
  30. data/app/javascript/content/application.js +35 -0
  31. data/app/{assets/javascripts/utils → javascript}/content/editor/container.js +1 -1
  32. data/app/{assets/javascripts/controllers → javascript}/content/editor/container_controller.js +3 -3
  33. data/app/{assets/javascripts/controllers → javascript}/content/editor/item_controller.js +1 -1
  34. data/app/{assets/javascripts/controllers → javascript}/content/editor/list_controller.js +12 -2
  35. data/app/{assets/javascripts/controllers → javascript}/content/editor/trix_controller.js +6 -1
  36. data/app/models/katalyst/content/types/nodes_type.rb +2 -2
  37. data/app/views/active_storage/blobs/_blob.html.erb +1 -1
  38. data/app/views/katalyst/content/asides/_aside.html+form.erb +2 -2
  39. data/app/views/katalyst/content/columns/_column.html+form.erb +2 -2
  40. data/app/views/katalyst/content/contents/_content.html+form.erb +3 -3
  41. data/app/views/katalyst/content/figures/_figure.html+form.erb +2 -2
  42. data/app/views/katalyst/content/groups/_group.html+form.erb +2 -2
  43. data/app/views/katalyst/content/items/_item.html+form.erb +2 -2
  44. data/app/views/katalyst/content/items/update.turbo_stream.erb +2 -2
  45. data/app/views/katalyst/content/sections/_section.html+form.erb +2 -2
  46. data/config/importmap.rb +1 -6
  47. data/lib/katalyst/content.rb +0 -1
  48. metadata +62 -25
  49. data/app/helpers/katalyst/content/editor/container.rb +0 -43
  50. data/app/helpers/katalyst/content/editor/errors.rb +0 -24
  51. data/app/helpers/katalyst/content/editor/item.rb +0 -67
  52. data/app/helpers/katalyst/content/editor/list.rb +0 -41
  53. data/app/helpers/katalyst/content/editor/new_item.rb +0 -53
  54. data/app/views/katalyst/content/editor/_item.html.erb +0 -14
  55. data/app/views/katalyst/content/editor/_new_item.html.erb +0 -3
  56. data/lib/katalyst/content/version.rb +0 -7
  57. /data/app/{assets/javascripts/utils → javascript}/content/editor/item.js +0 -0
  58. /data/app/{assets/javascripts/controllers → javascript}/content/editor/new_item_controller.js +0 -0
  59. /data/app/{assets/javascripts/utils/content/editor/rules-engine.js → javascript/content/editor/rules_engine.js} +0 -0
  60. /data/app/{assets/javascripts/controllers → javascript}/content/editor/status_bar_controller.js +0 -0
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Content
5
- module Editor
6
- class Item < Base
7
- attr_accessor :item
8
-
9
- def build(item, **options, &block)
10
- self.item = item
11
- tag.div **default_options(id: dom_id(item), **options) do
12
- concat(capture { yield self }) if block
13
- concat fields(item)
14
- end
15
- end
16
-
17
- def accordion_actions
18
- tag.div role: "toolbar", data: { tree_accordion_controls: "" } do
19
- concat tag.span(role: "button", value: "collapse",
20
- data: { action: "click->#{CONTAINER_CONTROLLER}#collapse", title: "Collapse tree" })
21
- concat tag.span(role: "button", value: "expand",
22
- data: { action: "click->#{CONTAINER_CONTROLLER}#expand", title: "Expand tree" })
23
- end
24
- end
25
-
26
- def item_actions
27
- tag.div role: "toolbar", data: { tree_controls: "" } do
28
- concat tag.span(role: "button", value: "de-nest",
29
- data: { action: "click->#{CONTAINER_CONTROLLER}#deNest", title: "Outdent" })
30
- concat tag.span(role: "button", value: "nest",
31
- data: { action: "click->#{CONTAINER_CONTROLLER}#nest", title: "Indent" })
32
- concat link_to("", edit_item_link,
33
- role: "button", title: "Edit", value: "edit",
34
- data: { turbo_frame: TURBO_FRAME })
35
- concat tag.span(role: "button", value: "remove",
36
- data: { action: "click->#{CONTAINER_CONTROLLER}#remove", title: "Remove" })
37
- end
38
- end
39
-
40
- def edit_item_link
41
- if item.persisted?
42
- katalyst_content.edit_item_path(item)
43
- else
44
- katalyst_content.new_item_path(item: item.attributes.slice("type", "container_id",
45
- "container_type").compact)
46
- end
47
- end
48
-
49
- def fields(item)
50
- template.fields(attributes_scope, model: item, index: nil, skip_default_ids: true) do |f|
51
- concat f.hidden_field(:id)
52
- concat f.hidden_field(:depth)
53
- concat f.hidden_field(:index)
54
- end
55
- end
56
-
57
- private
58
-
59
- def default_options(options)
60
- add_option(options, :data, :controller, ITEM_CONTROLLER)
61
-
62
- options
63
- end
64
- end
65
- end
66
- end
67
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Content
5
- module Editor
6
- class List < Base
7
- ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
8
- dragstart->#{LIST_CONTROLLER}#dragstart
9
- dragover->#{LIST_CONTROLLER}#dragover
10
- dragenter->#{LIST_CONTROLLER}#dragenter
11
- dragleave->#{LIST_CONTROLLER}#dragleave
12
- drop->#{LIST_CONTROLLER}#drop
13
- dragend->#{LIST_CONTROLLER}#dragend
14
- ACTIONS
15
-
16
- def build(options, &_block)
17
- tag.ol **default_options(id: container_form_id, **options) do
18
- yield self
19
- end
20
- end
21
-
22
- def items(*items)
23
- render partial: "katalyst/content/editor/item",
24
- layout: "katalyst/content/editor/list_item",
25
- collection: items,
26
- as: :item
27
- end
28
-
29
- private
30
-
31
- def default_options(options)
32
- add_option(options, :data, :controller, LIST_CONTROLLER)
33
- add_option(options, :data, :action, ACTIONS)
34
- add_option(options, :data, :"#{CONTAINER_CONTROLLER}_target", "container")
35
-
36
- options
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Content
5
- module Editor
6
- class NewItem < Base
7
- ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
8
- dragstart->#{NEW_ITEM_CONTROLLER}#dragstart
9
- ACTIONS
10
-
11
- def build(item, **options, &block)
12
- capture do
13
- concat(tag.div(**default_options(options)) do
14
- concat capture(&block)
15
- concat item_template(item)
16
- end)
17
- concat turbo_replace_placeholder(item)
18
- end
19
- end
20
-
21
- # Remove items that are incomplete when rendering new items, this
22
- # causes incomplete items to be removed from the list when the user
23
- # cancels adding a new item by pressing 'discard' in the new item form.
24
- def turbo_replace_placeholder(item)
25
- turbo_stream.replace dom_id(item) do
26
- content_editor_item(item: item, data: { delete: "" })
27
- end
28
- end
29
-
30
- # Template is stored inside the new item dom, and copied into drag
31
- # events when the user initiates drag so that it can be copied into the
32
- # editor list on drop.
33
- def item_template(item)
34
- tag.template data: { "#{NEW_ITEM_CONTROLLER}-target" => "template" } do
35
- content_editor_items(item: item)
36
- end
37
- end
38
-
39
- private
40
-
41
- def default_options(options)
42
- add_option(options, :draggable, true)
43
- add_option(options, :role, "listitem")
44
- add_option(options, :data, :turbo_frame, TURBO_FRAME)
45
- add_option(options, :data, :controller, NEW_ITEM_CONTROLLER)
46
- add_option(options, :data, :action, ACTIONS)
47
-
48
- options
49
- end
50
- end
51
- end
52
- end
53
- end
@@ -1,14 +0,0 @@
1
- <%= content_editor_item item: item do |builder| %>
2
- <div class="tree" data-invisible="<%= !item.visible? %>">
3
- <%= builder.accordion_actions %>
4
-
5
- <span role="img" value="<%= item.model_name.param_key %>" title="Type"></span>
6
- <h4 class="heading" title="<%= item.heading %>"><%= item.heading %></h4>
7
- <span role="img" value="invisible" title="Hidden"></span>
8
- </div>
9
-
10
- <div class="item-background <%= item.background %>">
11
- </div>
12
-
13
- <%= builder.item_actions %>
14
- <% end %>
@@ -1,3 +0,0 @@
1
- <%= content_editor_new_item item: item, data: { item_type: item.model_name.param_key } do %>
2
- <%= t(".#{item.model_name.param_key}", default: item.model_name.human) %>
3
- <% end %>
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Content
5
- VERSION = "1.1.0"
6
- end
7
- end