katalyst-content 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dabae0594160eb1ebafdd3501b5d521113fdcc8bde6f36eede4296314297255d
4
- data.tar.gz: aace7d35cd049a4c3fcf140f21099d5d04d03020a1935402e8999fa82c368823
3
+ metadata.gz: 15c10b4886c26310eb6a15c64f9b3c31b1b2dc312d9b4088bf530e6610ec3599
4
+ data.tar.gz: 2dd1d7e5179ff4d9f53d66b8ea99cd3d19f497e078d6234da4c8525e13a25ba1
5
5
  SHA512:
6
- metadata.gz: 452af88132002902aef2edfa6858e772a4985ea069cc6b1726c4acd9f3f2594fb84bf2e35a3377d233c5cfe1411caa5c7fc86c795b52d6c648d3a9c80bf616fe
7
- data.tar.gz: 1077d2f70a588105436e553b186f4cd3239a250ef36c2f10e15827973b8ea8375ca62b9b5c227d432f8642ef63a8ccdde832a6c89c482df6b99c79749811e78f
6
+ metadata.gz: 89a50df67af76c48e7978be76eee21da5100a8bf7fb69c6f580dc1868f4f644300f7d782b7cab61c2897717577e1cf4cc865a8b1f437c7d559c9b321f66b0bf0
7
+ data.tar.gz: c5dbc2983e3438642f38a58351010f7b110715ed865fb5851f1c43d4e8801a8c5a0e9bc0e371f5555cad72c976a3fc53d1bbc88cb6efc260d9403f1d0751f26c
@@ -41,9 +41,7 @@ export default class ContainerController extends Controller {
41
41
  nest(event) {
42
42
  const item = getEventItem(event);
43
43
 
44
- item.traverse((child) => {
45
- child.depth += 1;
46
- });
44
+ item.nest();
47
45
 
48
46
  this.#update();
49
47
  event.preventDefault();
@@ -52,9 +50,7 @@ export default class ContainerController extends Controller {
52
50
  deNest(event) {
53
51
  const item = getEventItem(event);
54
52
 
55
- item.traverse((child) => {
56
- child.depth -= 1;
57
- });
53
+ item.deNest();
58
54
 
59
55
  this.#update();
60
56
  event.preventDefault();
@@ -128,6 +128,39 @@ export default class Item {
128
128
  expanded.forEach((item) => item.traverse(callback));
129
129
  }
130
130
 
131
+ /**
132
+ * Increase the depth of this item and its descendants.
133
+ * If this causes it to become a child of a collapsed item, then collapse this item.
134
+ */
135
+ nest() {
136
+ this.traverse((child) => {
137
+ child.depth += 1;
138
+ });
139
+
140
+ if (this.previousItem.hasCollapsedDescendants()) {
141
+ this.previousItem.collapseChild(this);
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Move the given item into this element's hidden children list.
147
+ * Assumes the list already exists.
148
+ *
149
+ * @param item {Item}
150
+ */
151
+ collapseChild(item) {
152
+ this.#childrenListElement.appendChild(item.node);
153
+ }
154
+
155
+ /**
156
+ * Decrease the depth of this item (and its descendants).
157
+ */
158
+ deNest() {
159
+ this.traverse((child) => {
160
+ child.depth -= 1;
161
+ });
162
+ }
163
+
131
164
  /**
132
165
  * Collapses visible (logical) children into this element's hidden children
133
166
  * list, creating it if it doesn't already exist.
@@ -1,31 +1 @@
1
1
  @use "editor";
2
- @use "trix";
3
-
4
- /*
5
- * We need to override trix.css’s image gallery styles to accommodate the
6
- * <action-text-attachment> element we wrap around attachments. Otherwise,
7
- * images in galleries will be squished by the max-width: 33%; rule.
8
- */
9
- .trix-content .attachment-gallery > action-text-attachment,
10
- .trix-content .attachment-gallery > .attachment {
11
- flex: 1 0 33%;
12
- padding: 0 0.5em;
13
- max-width: 33%;
14
- }
15
-
16
- .trix-content
17
- .attachment-gallery.attachment-gallery--2
18
- > action-text-attachment,
19
- .trix-content .attachment-gallery.attachment-gallery--2 > .attachment,
20
- .trix-content
21
- .attachment-gallery.attachment-gallery--4
22
- > action-text-attachment,
23
- .trix-content .attachment-gallery.attachment-gallery--4 > .attachment {
24
- flex-basis: 50%;
25
- max-width: 50%;
26
- }
27
-
28
- .trix-content action-text-attachment .attachment {
29
- padding: 0 !important;
30
- max-width: 100% !important;
31
- }
@@ -4,6 +4,8 @@
4
4
  @use "item-rules";
5
5
  @use "new-items";
6
6
  @use "status-bar";
7
+ @use "trix";
8
+ @use "trix-rails";
7
9
 
8
10
  $grey-light: #f4f4f4 !default;
9
11
  $grey: #ececec !default;
@@ -99,8 +101,7 @@ $status-dirty-color: #aaa !default;
99
101
  align-items: center;
100
102
  }
101
103
 
102
- .title,
103
- .url {
104
+ .heading {
104
105
  text-overflow: ellipsis;
105
106
  overflow: hidden;
106
107
  white-space: nowrap;
@@ -111,14 +112,41 @@ $status-dirty-color: #aaa !default;
111
112
  [data-controller="content--editor--container"] [role="rowheader"],
112
113
  [data-controller="content--editor--item"] {
113
114
  display: grid;
114
- grid-template-columns: 40% 2fr auto;
115
+ grid-template-columns: minmax(10rem, calc(100% - 12rem)) 1fr 10rem;
115
116
  padding: 0.25rem 0.5rem;
116
117
  gap: 1rem;
117
118
  align-items: center;
118
119
  }
119
120
 
121
+ [data-controller="content--editor--item"] {
122
+ .item-background::before {
123
+ content: "A";
124
+ font-family: cursive;
125
+ display: inline-block;
126
+ min-height: 1rem;
127
+ min-width: 1rem;
128
+ text-align: center;
129
+ color: var(--theme-text-color);
130
+ background-color: var(--theme-background-color);
131
+ border: 1px solid var(--theme-border-color);
132
+ border-radius: 2px;
133
+ }
134
+
135
+ .item-background.light {
136
+ --theme-text-color: black;
137
+ --theme-border-color: black;
138
+ --theme-background-color: white;
139
+ }
140
+
141
+ .item-background.dark {
142
+ --theme-text-color: white;
143
+ --theme-border-color: white;
144
+ --theme-background-color: black;
145
+ }
146
+ }
147
+
120
148
  // Ensures vertical alignment of header with rows
121
- [data-controller="content--editor-container"] {
149
+ [data-controller="content--editor--container"] {
122
150
  [role="rowheader"] {
123
151
  min-height: var(--row-height);
124
152
  background: var(--table-header-color);
@@ -16,14 +16,14 @@
16
16
  [data-tree-controls] {
17
17
  [role="button"] {
18
18
  @extend %icon-block;
19
+
19
20
  &::before {
20
21
  @extend %icon;
21
22
  }
22
23
  }
23
24
  }
24
25
 
25
- [role="img"][value="link"],
26
- [role="img"][value="title"] {
26
+ [role="img"][value="content"] {
27
27
  width: 1.5rem;
28
28
  height: 1.5rem;
29
29
  display: grid;
@@ -45,15 +45,9 @@
45
45
  text-align: center;
46
46
  }
47
47
 
48
- &[value="link"] {
49
- &::before {
50
- content: "#";
51
- }
52
- }
53
-
54
- &[value="title"] {
48
+ &[value="content"] {
55
49
  &::before {
56
- content: "T";
50
+ background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 49 49' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.9 0C2.28667 0 0 2.28667 0 4.9C0 6.86 1.30667 8.82008 3.26667 9.47341V39.5266C1.30667 40.1799 0 42.14 0 44.1C0 46.7133 2.28667 49 4.9 49C6.86 49 8.82 47.6933 9.47333 45.7333H39.5267C40.18 47.6933 42.14 49 44.1 49C46.7133 49 49 46.7133 49 44.1C49 42.14 47.6933 40.1799 45.7333 39.5266V9.47341C47.6933 8.82008 49 6.86 49 4.9C49 2.28667 46.7133 0 44.1 0C42.14 0 40.18 1.30667 39.5267 3.26667H9.47333C8.82 1.30667 7.18667 0 4.9 0ZM4.9 3.26667C5.88 3.26667 6.53333 3.92 6.53333 4.9C6.53333 5.88 5.88 6.53333 4.9 6.53333C3.92 6.53333 3.26667 5.88 3.26667 4.9C3.26667 3.92 3.92 3.26667 4.9 3.26667ZM44.1 3.26667C45.08 3.26667 45.7333 3.92 45.7333 4.9C45.7333 5.88 45.08 6.53333 44.1 6.53333C43.12 6.53333 42.4667 5.88 42.4667 4.9C42.4667 3.92 43.12 3.26667 44.1 3.26667ZM9.47333 6.53333H39.5267C40.18 7.84 41.16 9.14675 42.4667 9.47341V39.5266C41.16 40.1799 39.8533 41.16 39.5267 42.4667H9.47333C8.82 41.16 7.84 39.8533 6.53333 39.5266V9.47341C7.84 8.82008 8.82 7.84 9.47333 6.53333ZM4.9 42.4667C5.88 42.4667 6.53333 43.12 6.53333 44.1C6.53333 45.08 5.88 45.7333 4.9 45.7333C3.92 45.7333 3.26667 45.08 3.26667 44.1C3.26667 43.12 3.92 42.4667 4.9 42.4667ZM44.1 42.4667C45.08 42.4667 45.7333 43.12 45.7333 44.1C45.7333 45.08 45.08 45.7333 44.1 45.7333C43.12 45.7333 42.4667 45.08 42.4667 44.1C42.4667 43.12 43.12 42.4667 44.1 42.4667Z' fill='white'/%3E%3Cpath d='M13 19.1667V11H35.8667V19.1667H32.6V14.2667H26.0667V33.8667H29.3333V37.1333H19.5333V33.8667H22.8V14.2667H16.2667V19.1667H13Z' fill='white'/%3E%3C/svg%3E");
57
51
  }
58
52
  }
59
53
  }
@@ -28,12 +28,8 @@
28
28
  position: unset;
29
29
  }
30
30
 
31
- &[data-item-type="link"]:before {
32
- background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0_67_1273)'%3E%3Cpath d='M16 22H32V26H16V22ZM40.2 24H44C44 18.48 39.52 14 34 14H26V17.8H34C37.42 17.8 40.2 20.58 40.2 24ZM7.8 24C7.8 20.58 10.58 17.8 14 17.8H22V14H14C8.48 14 4 18.48 4 24C4 29.52 8.48 34 14 34H22V30.2H14C10.58 30.2 7.8 27.42 7.8 24ZM38 24H34V30H28V34H34V40H38V34H44V30H38V24Z' /%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0_67_1273'%3E%3Crect width='48' height='48' /%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E");
33
- }
34
-
35
- &[data-item-type="button"]:before {
36
- background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0_67_1276)'%3E%3Cpath d='M44 18V30C44 32.2 42.2 34 40 34H38V30H40V18H8V30H20V34H8C5.8 34 4 32.2 4 30V18C4 15.8 5.8 14 8 14H40C42.2 14 44 15.8 44 18ZM29 38L31.18 33.18L36 31L31.18 28.82L29 24L26.82 28.82L22 31L26.82 33.18L29 38ZM34 28L35.24 25.24L38 24L35.24 22.76L34 20L32.76 22.76L30 24L32.76 25.24L34 28ZM29 38L31.18 33.18L36 31L31.18 28.82L29 24L26.82 28.82L22 31L26.82 33.18L29 38ZM34 28L35.24 25.24L38 24L35.24 22.76L34 20L32.76 22.76L30 24L32.76 25.24L34 28Z' /%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0_67_1276'%3E%3Crect width='48' height='48' /%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E");
31
+ &[data-item-type="content"]:before {
32
+ background-image: url("data:image/svg+xml,%3Csvg width='49' height='49' viewBox='0 0 49 49' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.9 0C2.28667 0 0 2.28667 0 4.9C0 6.86 1.30667 8.82008 3.26667 9.47341V39.5266C1.30667 40.1799 0 42.14 0 44.1C0 46.7133 2.28667 49 4.9 49C6.86 49 8.82 47.6933 9.47333 45.7333H39.5267C40.18 47.6933 42.14 49 44.1 49C46.7133 49 49 46.7133 49 44.1C49 42.14 47.6933 40.1799 45.7333 39.5266V9.47341C47.6933 8.82008 49 6.86 49 4.9C49 2.28667 46.7133 0 44.1 0C42.14 0 40.18 1.30667 39.5267 3.26667H9.47333C8.82 1.30667 7.18667 0 4.9 0ZM4.9 3.26667C5.88 3.26667 6.53333 3.92 6.53333 4.9C6.53333 5.88 5.88 6.53333 4.9 6.53333C3.92 6.53333 3.26667 5.88 3.26667 4.9C3.26667 3.92 3.92 3.26667 4.9 3.26667ZM44.1 3.26667C45.08 3.26667 45.7333 3.92 45.7333 4.9C45.7333 5.88 45.08 6.53333 44.1 6.53333C43.12 6.53333 42.4667 5.88 42.4667 4.9C42.4667 3.92 43.12 3.26667 44.1 3.26667ZM9.47333 6.53333H39.5267C40.18 7.84 41.16 9.14675 42.4667 9.47341V39.5266C41.16 40.1799 39.8533 41.16 39.5267 42.4667H9.47333C8.82 41.16 7.84 39.8533 6.53333 39.5266V9.47341C7.84 8.82008 8.82 7.84 9.47333 6.53333ZM4.9 42.4667C5.88 42.4667 6.53333 43.12 6.53333 44.1C6.53333 45.08 5.88 45.7333 4.9 45.7333C3.92 45.7333 3.26667 45.08 3.26667 44.1C3.26667 43.12 3.92 42.4667 4.9 42.4667ZM44.1 42.4667C45.08 42.4667 45.7333 43.12 45.7333 44.1C45.7333 45.08 45.08 45.7333 44.1 45.7333C43.12 45.7333 42.4667 45.08 42.4667 44.1C42.4667 43.12 43.12 42.4667 44.1 42.4667Z' /%3E%3Cpath d='M13 19.1667V11H35.8667V19.1667H32.6V14.2667H26.0667V33.8667H29.3333V37.1333H19.5333V33.8667H22.8V14.2667H16.2667V19.1667H13Z' /%3E%3C/svg%3E");
37
33
  }
38
34
  }
39
35
  }
@@ -0,0 +1,30 @@
1
+ // Rails-provided customizations to trix editor
2
+
3
+ /*
4
+ * We need to override trix.css’s image gallery styles to accommodate the
5
+ * <action-text-attachment> element we wrap around attachments. Otherwise,
6
+ * images in galleries will be squished by the max-width: 33%; rule.
7
+ */
8
+ .trix-content .attachment-gallery > action-text-attachment,
9
+ .trix-content .attachment-gallery > .attachment {
10
+ flex: 1 0 33%;
11
+ padding: 0 0.5em;
12
+ max-width: 33%;
13
+ }
14
+
15
+ .trix-content
16
+ .attachment-gallery.attachment-gallery--2
17
+ > action-text-attachment,
18
+ .trix-content .attachment-gallery.attachment-gallery--2 > .attachment,
19
+ .trix-content
20
+ .attachment-gallery.attachment-gallery--4
21
+ > action-text-attachment,
22
+ .trix-content .attachment-gallery.attachment-gallery--4 > .attachment {
23
+ flex-basis: 50%;
24
+ max-width: 50%;
25
+ }
26
+
27
+ .trix-content action-text-attachment .attachment {
28
+ padding: 0 !important;
29
+ max-width: 100% !important;
30
+ }
@@ -2,10 +2,13 @@
2
2
  <div class="tree" data-invisible="<%= !item.visible? %>">
3
3
  <%= builder.accordion_actions %>
4
4
 
5
- <span role="img" value="<%= item.model_name.to_param %>" title="Type"></span>
5
+ <span role="img" value="<%= item.model_name.param_key %>" title="Type"></span>
6
6
  <h4 class="heading" title="<%= item.heading %>"><%= item.heading %></h4>
7
7
  <span role="img" value="invisible" title="Hidden"></span>
8
8
  </div>
9
9
 
10
+ <div class="item-background <%= item.background %>">
11
+ </div>
12
+
10
13
  <%= builder.item_actions %>
11
14
  <% end %>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Katalyst
4
4
  module Content
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-14 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -35,6 +35,7 @@ files:
35
35
  - app/assets/stylesheets/katalyst/content/editor/_item-rules.scss
36
36
  - app/assets/stylesheets/katalyst/content/editor/_new-items.scss
37
37
  - app/assets/stylesheets/katalyst/content/editor/_status-bar.scss
38
+ - app/assets/stylesheets/katalyst/content/editor/_trix-rails.scss
38
39
  - app/controllers/katalyst/content/application_controller.rb
39
40
  - app/controllers/katalyst/content/items_controller.rb
40
41
  - app/helpers/katalyst/content/application_helper.rb