katalyst-content 2.7.1 → 3.0.0.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/app/assets/builds/katalyst/content.esm.js +208 -110
- data/app/assets/builds/katalyst/content.js +208 -110
- data/app/assets/builds/katalyst/content.min.js +1 -1
- data/app/assets/builds/katalyst/content.min.js.map +1 -1
- data/app/assets/images/katalyst/content/icons/aside.svg +1 -0
- data/app/assets/images/katalyst/content/icons/collapse.svg +3 -0
- data/app/assets/images/katalyst/content/icons/column.svg +1 -0
- data/app/assets/images/katalyst/content/icons/content.svg +1 -0
- data/app/assets/images/katalyst/content/icons/edit.svg +1 -0
- data/app/assets/images/katalyst/content/icons/expand.svg +3 -0
- data/app/assets/images/katalyst/content/icons/figure.svg +1 -0
- data/app/assets/images/katalyst/content/icons/group.svg +1 -0
- data/app/assets/images/katalyst/content/icons/hidden.svg +1 -0
- data/app/assets/images/katalyst/content/icons/indent.svg +3 -0
- data/app/assets/images/katalyst/content/icons/outdent.svg +4 -0
- data/app/assets/images/katalyst/content/icons/remove.svg +1 -0
- data/app/assets/images/katalyst/content/icons/section.svg +1 -0
- data/app/assets/images/katalyst/content/icons/table.svg +1 -0
- data/app/assets/images/katalyst/content/icons/theme.svg +1 -0
- data/app/assets/stylesheets/katalyst/_content.scss +4 -0
- data/app/assets/stylesheets/katalyst/content/editor.css +196 -0
- data/app/assets/stylesheets/katalyst/content/icons.css +79 -0
- data/app/assets/stylesheets/katalyst/content/{editor/_status-bar.scss → status-bar.css} +31 -37
- data/app/assets/stylesheets/katalyst/content/{editor/_table.scss → table.css} +3 -5
- data/app/assets/stylesheets/katalyst/content.css +4 -0
- data/app/components/katalyst/content/editor/base_component.rb +0 -6
- data/app/components/katalyst/content/editor/item_component.html.erb +31 -15
- data/app/components/katalyst/content/editor/item_component.rb +1 -3
- data/app/components/katalyst/content/editor/item_editor_component.rb +8 -22
- data/app/components/katalyst/content/editor/new_item_component.html.erb +15 -22
- data/app/components/katalyst/content/editor/new_item_component.rb +7 -10
- data/app/components/katalyst/content/editor/new_items_component.html.erb +41 -2
- data/app/components/katalyst/content/editor/new_items_component.rb +0 -2
- data/app/components/katalyst/content/editor/row_component.html.erb +2 -1
- data/app/components/katalyst/content/editor/status_bar_component.rb +9 -11
- data/app/components/katalyst/content/editor/table_component.html.erb +0 -6
- data/app/components/katalyst/content/editor/table_component.rb +12 -14
- data/app/components/katalyst/content/editor_component.html.erb +7 -0
- data/app/components/katalyst/content/editor_component.rb +15 -12
- data/app/controllers/katalyst/content/application_controller.rb +1 -0
- data/app/controllers/katalyst/content/items_controller.rb +2 -3
- data/app/javascript/content/application.js +8 -3
- data/app/javascript/content/editor/item.js +1 -1
- data/app/javascript/content/editor/item_editor_controller.js +57 -0
- data/app/javascript/content/editor/list_controller.js +11 -104
- data/app/javascript/content/editor/new_items_controller.js +143 -0
- data/app/views/katalyst/content/asides/_aside.html+form.erb +22 -26
- data/app/views/katalyst/content/columns/_column.html+form.erb +18 -22
- data/app/views/katalyst/content/contents/_content.html+form.erb +22 -26
- data/app/views/katalyst/content/figures/_figure.html+form.erb +27 -31
- data/app/views/katalyst/content/groups/_group.html+form.erb +18 -22
- data/app/views/katalyst/content/items/_form.html.erb +6 -0
- data/app/views/katalyst/content/items/_item.html+form.erb +18 -22
- data/app/views/katalyst/content/items/edit.html.erb +40 -2
- data/app/views/katalyst/content/items/edit.turbo_stream.erb +2 -0
- data/app/views/katalyst/content/items/update.turbo_stream.erb +0 -1
- data/app/views/katalyst/content/sections/_section.html+form.erb +18 -22
- data/app/views/katalyst/content/tables/_table.html+form.erb +7 -9
- data/lib/katalyst/content/engine.rb +0 -1
- metadata +26 -28
- data/app/assets/stylesheets/katalyst/content/_index.scss +0 -1
- data/app/assets/stylesheets/katalyst/content/editor/_figure.scss +0 -12
- data/app/assets/stylesheets/katalyst/content/editor/_icon.scss +0 -17
- data/app/assets/stylesheets/katalyst/content/editor/_index.scss +0 -157
- data/app/assets/stylesheets/katalyst/content/editor/_item-actions.scss +0 -110
- data/app/assets/stylesheets/katalyst/content/editor/_item-rules.scss +0 -19
- data/app/assets/stylesheets/katalyst/content/editor/_new-items.scss +0 -83
- data/app/assets/stylesheets/katalyst/content/editor/_trix-rails.scss +0 -30
- data/app/assets/stylesheets/katalyst/content/editor/_variables.scss +0 -26
- data/app/javascript/content/editor/new_item_controller.js +0 -12
@@ -1,25 +1,39 @@
|
|
1
1
|
[data-controller="content--editor--status-bar"] {
|
2
|
+
--background: #ebf9eb;
|
3
|
+
--color: #4dd45c;
|
4
|
+
--border: #4dd45c;
|
5
|
+
|
6
|
+
display: grid;
|
7
|
+
grid-template-columns: 1fr auto;
|
8
|
+
grid-template-areas: "status actions";
|
9
|
+
align-items: baseline;
|
10
|
+
grid-column-gap: 2rem;
|
11
|
+
|
2
12
|
min-height: 3rem;
|
3
13
|
line-height: 3rem;
|
4
|
-
padding:
|
14
|
+
padding-inline: var(--space-m);
|
5
15
|
background: var(--background);
|
6
16
|
color: var(--color);
|
7
17
|
border: 1px solid var(--border);
|
8
18
|
margin-bottom: 1rem;
|
9
|
-
white-space: nowrap;
|
10
19
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
20
|
+
&[data-state="draft"],
|
21
|
+
&[data-state="unpublished"] {
|
22
|
+
--background: #fefaf3;
|
23
|
+
--color: #ffa800;
|
24
|
+
--border: #ffa800;
|
25
|
+
}
|
26
|
+
|
27
|
+
&[data-state="dirty"] {
|
28
|
+
--background: #eee;
|
29
|
+
--color: #aaa;
|
30
|
+
--border: #888;
|
31
|
+
}
|
15
32
|
|
16
33
|
.status-text {
|
17
34
|
display: none;
|
18
35
|
grid-area: status;
|
19
36
|
font-weight: bold;
|
20
|
-
color: var(--color);
|
21
|
-
overflow: hidden;
|
22
|
-
text-overflow: ellipsis;
|
23
37
|
}
|
24
38
|
|
25
39
|
&[data-state="published"] .status-text[data-published],
|
@@ -29,44 +43,24 @@
|
|
29
43
|
display: unset;
|
30
44
|
}
|
31
45
|
|
46
|
+
button {
|
47
|
+
--button-bg: var(--color);
|
48
|
+
--button-hover-bg: var(--color);
|
49
|
+
}
|
50
|
+
|
32
51
|
menu {
|
33
|
-
display: inline;
|
52
|
+
display: inline-flex;
|
34
53
|
grid-area: actions;
|
35
54
|
margin: 0;
|
36
55
|
padding: 0;
|
56
|
+
gap: var(--space-3xs, 0.25rem);
|
57
|
+
align-items: baseline;
|
37
58
|
}
|
38
59
|
|
39
60
|
menu > li {
|
40
61
|
display: inline;
|
41
62
|
}
|
42
63
|
|
43
|
-
.button {
|
44
|
-
color: inherit;
|
45
|
-
line-height: 1rem;
|
46
|
-
margin-left: 0.5rem;
|
47
|
-
}
|
48
|
-
|
49
|
-
.button--primary {
|
50
|
-
background: var(--color);
|
51
|
-
border: 1px solid var(--border);
|
52
|
-
color: white;
|
53
|
-
|
54
|
-
&[disabled] {
|
55
|
-
background: var(--color);
|
56
|
-
opacity: 0.8;
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
.button--secondary {
|
61
|
-
background: var(--background);
|
62
|
-
border: 1px solid var(--border);
|
63
|
-
color: var(--color);
|
64
|
-
|
65
|
-
&[disabled] {
|
66
|
-
background: var(--background);
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
64
|
&[data-state="published"] {
|
71
65
|
[value="publish"],
|
72
66
|
[value="save"],
|
@@ -1,5 +1,3 @@
|
|
1
|
-
@use "variables" as *;
|
2
|
-
|
3
1
|
[data-content--editor--table-target="content"] {
|
4
2
|
position: relative;
|
5
3
|
min-height: 8rem;
|
@@ -26,17 +24,17 @@
|
|
26
24
|
|
27
25
|
th,
|
28
26
|
td {
|
29
|
-
border: 1px solid
|
27
|
+
border: 1px solid var(--color-mid, #9ca3af);
|
30
28
|
padding: 0.25rem 0.5rem;
|
31
29
|
text-align: left;
|
32
30
|
vertical-align: top;
|
33
31
|
}
|
34
32
|
|
35
33
|
thead {
|
36
|
-
background-color:
|
34
|
+
background-color: var(--color-mid, #9ca3af);
|
37
35
|
}
|
38
36
|
|
39
37
|
tbody th {
|
40
|
-
background-color:
|
38
|
+
background-color: var(--color-tint, #f0ecf3);
|
41
39
|
}
|
42
40
|
}
|
@@ -6,12 +6,6 @@ module Katalyst
|
|
6
6
|
class BaseComponent < ViewComponent::Base
|
7
7
|
include Katalyst::HtmlAttributes
|
8
8
|
|
9
|
-
CONTAINER_CONTROLLER = "content--editor--container"
|
10
|
-
LIST_CONTROLLER = "content--editor--list"
|
11
|
-
ITEM_CONTROLLER = "content--editor--item"
|
12
|
-
STATUS_BAR_CONTROLLER = "content--editor--status-bar"
|
13
|
-
NEW_ITEM_CONTROLLER = "content--editor--new-item"
|
14
|
-
|
15
9
|
attr_accessor :container, :item
|
16
10
|
|
17
11
|
delegate :config, to: ::Katalyst::Content
|
@@ -1,22 +1,38 @@
|
|
1
1
|
<%= tag.div(**html_attributes) do %>
|
2
|
-
<div class="tree"
|
3
|
-
<
|
4
|
-
<span role="button" value="collapse" data-action="click-><%= CONTAINER_CONTROLLER %>#collapse" title="Collapse tree"></span>
|
5
|
-
<span role="button" value="expand" data-action="click-><%= CONTAINER_CONTROLLER %>#expand" title="Expand tree"></span>
|
6
|
-
</div>
|
2
|
+
<div class="tree">
|
3
|
+
<icon class="icon" data-icon="<%= item.model_name.param_key %>" aria-hidden="true"> </icon>
|
7
4
|
|
8
|
-
<
|
9
|
-
|
10
|
-
<span
|
11
|
-
|
5
|
+
<strong class="heading" title="<%= item.heading %>"><%= item.heading %></strong>
|
6
|
+
|
7
|
+
<span class="item-background <%= item.background %>">
|
8
|
+
<icon class="icon" data-icon="theme" role="img"> </icon>
|
9
|
+
</span>
|
12
10
|
|
13
|
-
|
11
|
+
<% unless item.visible? %>
|
12
|
+
<icon class="icon" data-icon="hidden" title="Hidden" role="img"> </icon>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
14
15
|
|
15
|
-
<div role="toolbar"
|
16
|
-
<
|
17
|
-
|
18
|
-
|
19
|
-
<
|
16
|
+
<div role="toolbar" class="actions-group">
|
17
|
+
<button class="button" data-button-padding="tight" data-text-button data-action="content--editor--container#collapse" title="Collapse tree">
|
18
|
+
<icon class="icon" data-icon="collapse" role="img"> </icon>
|
19
|
+
</button>
|
20
|
+
<button class="button" data-button-padding="tight" data-text-button data-action="content--editor--container#expand" title="Expand tree">
|
21
|
+
<icon class="icon" data-icon="expand" role="img"> </icon>
|
22
|
+
</button>
|
23
|
+
<button class="button" data-button-padding="tight" data-text-button data-action="content--editor--container#deNest" title="Outdent">
|
24
|
+
<icon class="icon" data-icon="outdent" role="img"> </icon>
|
25
|
+
</button>
|
26
|
+
<button class="button" data-button-padding="tight" data-text-button data-action="content--editor--container#nest" title="Indent">
|
27
|
+
<icon class="icon" data-icon="indent" role="img"> </icon>
|
28
|
+
</button>
|
29
|
+
<%= link_to(edit_item_link, class: "button", title: "Edit", value: "edit",
|
30
|
+
data: { text_button: "", button_padding: "tight", turbo_frame: "content--editor--item-editor" }) do %>
|
31
|
+
<icon class="icon" data-icon="edit" role="img"> </icon>
|
32
|
+
<% end %>
|
33
|
+
<button class="button" data-button-padding="tight" data-text-button data-action="content--editor--container#remove" title="Remove">
|
34
|
+
<icon class="icon" data-icon="remove" role="img"> </icon>
|
35
|
+
</button>
|
20
36
|
</div>
|
21
37
|
|
22
38
|
<input autocomplete="off" type="hidden" name="<%= attributes_scope %>[id]" value="<%= item.id %>">
|
@@ -4,8 +4,6 @@ module Katalyst
|
|
4
4
|
module Content
|
5
5
|
module Editor
|
6
6
|
class ItemComponent < BaseComponent
|
7
|
-
include KpopHelper
|
8
|
-
|
9
7
|
def edit_item_link
|
10
8
|
if item.persisted?
|
11
9
|
helpers.katalyst_content.edit_item_path(item)
|
@@ -20,7 +18,7 @@ module Katalyst
|
|
20
18
|
{
|
21
19
|
id: dom_id(item),
|
22
20
|
data: {
|
23
|
-
controller:
|
21
|
+
controller: "content--editor--item",
|
24
22
|
},
|
25
23
|
}
|
26
24
|
end
|
@@ -6,25 +6,18 @@ module Katalyst
|
|
6
6
|
class ItemEditorComponent < BaseComponent
|
7
7
|
include ::Turbo::FramesHelper
|
8
8
|
|
9
|
-
|
10
|
-
def prefix_partial_path_with_controller_namespace
|
11
|
-
false
|
12
|
-
end
|
13
|
-
|
14
|
-
def content_routes
|
15
|
-
katalyst_content
|
16
|
-
end
|
17
|
-
end
|
9
|
+
alias_method :model, :item
|
18
10
|
|
19
11
|
def call
|
20
|
-
|
21
|
-
helpers.extend(Helpers)
|
22
|
-
helpers.render(item, path:)
|
23
|
-
end
|
12
|
+
render("form", model:, scope:, url:, id:)
|
24
13
|
end
|
25
14
|
|
26
15
|
def id
|
27
|
-
|
16
|
+
dom_id(item, :form)
|
17
|
+
end
|
18
|
+
|
19
|
+
def scope
|
20
|
+
:item
|
28
21
|
end
|
29
22
|
|
30
23
|
def title
|
@@ -35,20 +28,13 @@ module Katalyst
|
|
35
28
|
end
|
36
29
|
end
|
37
30
|
|
38
|
-
def
|
31
|
+
def url
|
39
32
|
if item.persisted?
|
40
33
|
view_context.katalyst_content.item_path(item)
|
41
34
|
else
|
42
35
|
view_context.katalyst_content.items_path
|
43
36
|
end
|
44
37
|
end
|
45
|
-
|
46
|
-
def default_html_attributes
|
47
|
-
{
|
48
|
-
id:,
|
49
|
-
class: "content--item-editor",
|
50
|
-
}
|
51
|
-
end
|
52
38
|
end
|
53
39
|
end
|
54
40
|
end
|
@@ -1,22 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<% end %>
|
15
|
-
|
16
|
-
# Remove items that are incomplete when rendering new items, this
|
17
|
-
# causes incomplete items to be removed from the list when the user
|
18
|
-
# cancels adding a new item by pressing 'discard' in the new item form.
|
19
|
-
%>
|
20
|
-
<%= turbo_stream.replace dom_id(item) do %>
|
21
|
-
<%= render item_component(data: { delete: "" }) %>
|
22
|
-
<% end %>
|
1
|
+
<li>
|
2
|
+
<%= tag.button(**html_attributes) do %>
|
3
|
+
<icon class="icon" data-icon="<%= icon_name %>" role="img"> </icon>
|
4
|
+
<%= label %>
|
5
|
+
<%#
|
6
|
+
# Template is stored inside the new item dom, and copied into the dom when
|
7
|
+
# the user selects the item.
|
8
|
+
%>
|
9
|
+
<template>
|
10
|
+
<%= render row_component do %>
|
11
|
+
<%= render item_component %>
|
12
|
+
<% end %>
|
13
|
+
</template>
|
14
|
+
<% end %>
|
15
|
+
</li>
|
@@ -8,10 +8,6 @@ module Katalyst
|
|
8
8
|
|
9
9
|
with_collection_parameter :item
|
10
10
|
|
11
|
-
ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
|
12
|
-
dragstart->#{NEW_ITEM_CONTROLLER}#dragstart
|
13
|
-
ACTIONS
|
14
|
-
|
15
11
|
def initialize(item:, container: item.container)
|
16
12
|
super
|
17
13
|
end
|
@@ -32,16 +28,17 @@ module Katalyst
|
|
32
28
|
item.model_name.param_key
|
33
29
|
end
|
34
30
|
|
31
|
+
alias icon_name item_type
|
32
|
+
|
35
33
|
private
|
36
34
|
|
37
35
|
def default_html_attributes
|
38
36
|
{
|
39
|
-
|
40
|
-
role:
|
41
|
-
data:
|
42
|
-
|
43
|
-
|
44
|
-
action: ACTIONS,
|
37
|
+
class: "button",
|
38
|
+
role: "listitem",
|
39
|
+
data: {
|
40
|
+
ghost_button: "",
|
41
|
+
action: "content--editor--new-items#add",
|
45
42
|
},
|
46
43
|
}
|
47
44
|
end
|
@@ -1,3 +1,42 @@
|
|
1
|
-
<div class="content--editor--new-items"
|
2
|
-
|
1
|
+
<div class="content--editor--new-items"
|
2
|
+
data-controller="content--editor--new-items"
|
3
|
+
data-action="turbo:before-morph-element->content--editor--new-items#morph">
|
4
|
+
<button aria-controls="content--editor--new-items-dialog"
|
5
|
+
class="button"
|
6
|
+
data-action="click->content--editor--new-items#open"
|
7
|
+
data-button-padding="tight"
|
8
|
+
data-text-button>
|
9
|
+
<icon aria-hidden="true" class="icon" data-icon="add"> </icon>
|
10
|
+
Add item
|
11
|
+
</button>
|
12
|
+
<div class="content--editor--inline-add" data-content--editor--new-items-target="inline" hidden>
|
13
|
+
<button aria-controls="content--editor--new-items-dialog"
|
14
|
+
class="button"
|
15
|
+
data-action="content--editor--new-items#open"
|
16
|
+
data-button-padding="tight">
|
17
|
+
<icon aria-hidden="true" class="icon" data-icon="add"> </icon>
|
18
|
+
<span class="visually-hidden">Add item here</span>
|
19
|
+
</button>
|
20
|
+
</div>
|
21
|
+
<dialog id="content--editor--new-items-dialog" class="modal" data-action="click->content--editor--new-items#close">
|
22
|
+
<article class="flow" data-action="click->content--editor--new-items#noop:stop">
|
23
|
+
<header class="repel" data-nowrap>
|
24
|
+
<h2>Add item</h2>
|
25
|
+
<button class="button"
|
26
|
+
data-action="click->content--editor--new-items#close"
|
27
|
+
data-button-padding="tight"
|
28
|
+
data-text-button>
|
29
|
+
<icon aria-hidden="true" class="icon" data-icon="close"> </icon>
|
30
|
+
<span class="visually-hidden">Close</span>
|
31
|
+
</button>
|
32
|
+
</header>
|
33
|
+
<main>
|
34
|
+
<%= tag.div(role: "list", data: { action: "click->content--editor--new-items#noop:stop" }) do %>
|
35
|
+
<ul role="list" class="items-list">
|
36
|
+
<%= render Katalyst::Content::Editor::NewItemComponent.with_collection(items) %>
|
37
|
+
</ul>
|
38
|
+
<% end %>
|
39
|
+
</main>
|
40
|
+
</article>
|
41
|
+
</dialog>
|
3
42
|
</div>
|
@@ -4,11 +4,6 @@ module Katalyst
|
|
4
4
|
module Content
|
5
5
|
module Editor
|
6
6
|
class StatusBarComponent < BaseComponent
|
7
|
-
ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
|
8
|
-
content:change@document->#{STATUS_BAR_CONTROLLER}#change
|
9
|
-
turbo:morph-element->#{STATUS_BAR_CONTROLLER}#morph
|
10
|
-
ACTIONS
|
11
|
-
|
12
7
|
attr_reader :container
|
13
8
|
|
14
9
|
def call
|
@@ -37,10 +32,10 @@ module Katalyst
|
|
37
32
|
|
38
33
|
def actions
|
39
34
|
tag.menu do
|
40
|
-
concat action(:discard, class: "button
|
41
|
-
concat action(:revert, class: "button
|
42
|
-
concat action(:save, class: "button
|
43
|
-
concat action(:publish, class: "button
|
35
|
+
concat action(:discard, class: "button", data: { text_button: "" })
|
36
|
+
concat action(:revert, class: "button", data: { text_button: "" })
|
37
|
+
concat action(:save, class: "button", data: { ghost_button: "" })
|
38
|
+
concat action(:publish, class: "button")
|
44
39
|
end
|
45
40
|
end
|
46
41
|
|
@@ -59,8 +54,11 @@ module Katalyst
|
|
59
54
|
def default_html_attributes
|
60
55
|
{
|
61
56
|
data: {
|
62
|
-
controller:
|
63
|
-
action:
|
57
|
+
controller: "content--editor--status-bar",
|
58
|
+
action: %w[
|
59
|
+
content:change@document->content--editor--status-bar#change
|
60
|
+
turbo:morph-element->content--editor--status-bar#morph
|
61
|
+
],
|
64
62
|
state: container.state,
|
65
63
|
},
|
66
64
|
}
|
@@ -4,16 +4,6 @@ module Katalyst
|
|
4
4
|
module Content
|
5
5
|
module Editor
|
6
6
|
class TableComponent < BaseComponent
|
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
|
-
keyup.esc@document->#{LIST_CONTROLLER}#dragend
|
15
|
-
ACTIONS
|
16
|
-
|
17
7
|
renders_many :items, ->(item) do
|
18
8
|
row = RowComponent.new(item:, container:)
|
19
9
|
row.with_content(render(ItemComponent.new(item:, container:)))
|
@@ -24,11 +14,19 @@ module Katalyst
|
|
24
14
|
|
25
15
|
def default_html_attributes
|
26
16
|
{
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
17
|
+
class: "katalyst--content--editor",
|
18
|
+
data: {
|
19
|
+
controller: "content--editor--list",
|
20
|
+
action: %w[
|
21
|
+
dragstart->content--editor--list#dragstart
|
22
|
+
dragover->content--editor--list#dragover
|
23
|
+
drop->content--editor--list#drop
|
24
|
+
dragend->content--editor--list#dragend
|
25
|
+
keyup.esc@document->content--editor--list#dragend
|
26
|
+
],
|
27
|
+
content__editor__container_target: "container",
|
31
28
|
},
|
29
|
+
role: "list",
|
32
30
|
}
|
33
31
|
end
|
34
32
|
end
|
@@ -6,4 +6,11 @@
|
|
6
6
|
<%= render Katalyst::Content::Editor::TableComponent.new(container:) do |list| %>
|
7
7
|
<%= container.draft_items&.each { |item| list.with_item(item) } %>
|
8
8
|
<% end %>
|
9
|
+
|
10
|
+
<%= render Katalyst::Content::Editor::NewItemsComponent.new(container:) %>
|
9
11
|
<% end %>
|
12
|
+
|
13
|
+
<%= turbo_frame_tag(
|
14
|
+
"content--editor--item-editor",
|
15
|
+
data: { controller: "content--editor--item-editor" },
|
16
|
+
) %>
|
@@ -3,13 +3,7 @@
|
|
3
3
|
module Katalyst
|
4
4
|
module Content
|
5
5
|
class EditorComponent < Editor::BaseComponent
|
6
|
-
|
7
|
-
submit->#{CONTAINER_CONTROLLER}#reindex
|
8
|
-
content:drop->#{CONTAINER_CONTROLLER}#drop
|
9
|
-
content:reindex->#{CONTAINER_CONTROLLER}#reindex
|
10
|
-
turbo:render@document->#{CONTAINER_CONTROLLER}#connect
|
11
|
-
content:reset->#{CONTAINER_CONTROLLER}#reset
|
12
|
-
ACTIONS
|
6
|
+
include ::Turbo::FramesHelper
|
13
7
|
|
14
8
|
attr_reader :url, :scope
|
15
9
|
|
@@ -24,8 +18,10 @@ module Katalyst
|
|
24
18
|
Editor::StatusBarComponent.new(container:)
|
25
19
|
end
|
26
20
|
|
21
|
+
# @deprecated this component is now part of the editor
|
27
22
|
def new_items
|
28
|
-
|
23
|
+
# no-op, no longer required
|
24
|
+
Class.new { define_method(:render_in) { |_| nil } }.new
|
29
25
|
end
|
30
26
|
|
31
27
|
def item_editor(item:)
|
@@ -42,10 +38,17 @@ module Katalyst
|
|
42
38
|
|
43
39
|
def default_html_attributes
|
44
40
|
{
|
45
|
-
id:
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
id: container_form_id,
|
42
|
+
class: "content--editor",
|
43
|
+
data: {
|
44
|
+
controller: "content--editor--container",
|
45
|
+
action: %w[
|
46
|
+
submit->content--editor--container#reindex
|
47
|
+
content:drop->content--editor--container#drop
|
48
|
+
content:reindex->content--editor--container#reindex
|
49
|
+
turbo:render@document->content--editor--container#connect
|
50
|
+
content:reset->content--editor--container#reset
|
51
|
+
],
|
49
52
|
},
|
50
53
|
}
|
51
54
|
end
|
@@ -6,7 +6,6 @@ module Katalyst
|
|
6
6
|
before_action :set_container, only: %i[new create]
|
7
7
|
before_action :set_item, except: %i[new create]
|
8
8
|
before_action :set_editor_variant
|
9
|
-
before_action :require_kpop, only: %i[new edit]
|
10
9
|
|
11
10
|
attr_reader :container, :item, :editor
|
12
11
|
|
@@ -48,8 +47,8 @@ module Katalyst
|
|
48
47
|
private
|
49
48
|
|
50
49
|
def item_params_type
|
51
|
-
|
52
|
-
if Katalyst::Content.config.items.
|
50
|
+
requested_type = params.require(:item).fetch(:type, "")
|
51
|
+
if (type = Katalyst::Content.config.items.find { |t| t == requested_type })
|
53
52
|
type.safe_constantize
|
54
53
|
else
|
55
54
|
Item
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import ContainerController from "./editor/container_controller";
|
2
2
|
import ItemController from "./editor/item_controller";
|
3
|
+
import ItemEditorController from "./editor/item_editor_controller";
|
3
4
|
import ListController from "./editor/list_controller";
|
4
|
-
import
|
5
|
+
import NewItemsController from "./editor/new_items_controller";
|
5
6
|
import StatusBarController from "./editor/status_bar_controller";
|
6
7
|
import TableController from "./editor/table_controller";
|
7
8
|
import TrixController from "./editor/trix_controller";
|
@@ -15,13 +16,17 @@ const Definitions = [
|
|
15
16
|
identifier: "content--editor--item",
|
16
17
|
controllerConstructor: ItemController,
|
17
18
|
},
|
19
|
+
{
|
20
|
+
identifier: "content--editor--item-editor",
|
21
|
+
controllerConstructor: ItemEditorController,
|
22
|
+
},
|
18
23
|
{
|
19
24
|
identifier: "content--editor--list",
|
20
25
|
controllerConstructor: ListController,
|
21
26
|
},
|
22
27
|
{
|
23
|
-
identifier: "content--editor--new-
|
24
|
-
controllerConstructor:
|
28
|
+
identifier: "content--editor--new-items",
|
29
|
+
controllerConstructor: NewItemsController,
|
25
30
|
},
|
26
31
|
{
|
27
32
|
identifier: "content--editor--status-bar",
|
@@ -272,7 +272,7 @@ export default class Item {
|
|
272
272
|
*/
|
273
273
|
function createChildrenList(node) {
|
274
274
|
const childrenList = document.createElement("ol");
|
275
|
-
childrenList.
|
275
|
+
childrenList.toggleAttribute("hidden", true);
|
276
276
|
|
277
277
|
// if objectType is "rich-content" set richContentChildren as a data attribute
|
278
278
|
childrenList.dataset[`contentChildren`] = "";
|