playbook_ui 14.1.0.pre.alpha.PA1477timestampkit3601 → 14.1.0.pre.alpha.PBNTR449rtepreviewerrails3605

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b32c41e2625eea89ee6d671ece56d4d4924876e36e62147d4d084e8437a979b6
4
- data.tar.gz: fa213c730648a601b22a7bce64ce0fbb280f69b17b37bb16f2bb2ce8350a2747
3
+ metadata.gz: a8d134303f815c6e0076c01a0aa625cda4c97ceff14ec8eff52b2716ebbb60a8
4
+ data.tar.gz: 1188d83da657ab95a2c0fb418f04734f2039c73278e1191fc8b75b14a37348f4
5
5
  SHA512:
6
- metadata.gz: 829ba2957858c5ab84f149c949b772fe19be179440ea1f8bf86cda41dbf2b91b6100fbd8c9b3c562b7766f6e6711e8a65db97b83603ab3e1ec940f584f36e1c5
7
- data.tar.gz: 654fa901ba9fc4136daf62d5daf0c160bebb1462b56f28c5e990e3405b0d9393f48fdd08794cf205925e3dd5390aaaca59054bce941d500a1e9a2440264876a9
6
+ metadata.gz: d04fdd2687e6accfad40120bbeba65830b7be5c3a15157d21a2ed1cd7b4d0c13202179cf5eeece62f5a7f21559e79af4da3760f7b83ef76ad70c7df607563a75
7
+ data.tar.gz: 173ab72b24320b444d7f5930fd41e2fae8a2122bacf85e46f142ac8860d05d12dcee0111bcd730ebbdba5586fdceab590667b7c560f921218140e46803b46f06
@@ -3,18 +3,20 @@
3
3
  @import "../tokens/spacing";
4
4
  @import "../tokens/typography";
5
5
 
6
- @mixin preview_first_child {
6
+
7
+ // Tiptap mixins section (React Advanced Editor)
8
+ @mixin preview_tiptap_first_child {
7
9
  :first-child {
8
10
  margin-top: 0;
9
11
  }
10
12
  }
11
13
 
12
- @mixin preview_p {
14
+ @mixin preview_tiptap_p {
13
15
  margin: 1rem 0 0 0;
14
16
  min-height: 1rem;
15
17
  }
16
18
 
17
- @mixin preview_code {
19
+ @mixin preview_tiptap_code {
18
20
  font-family: monospace;
19
21
  background: $bg_light;
20
22
  padding: 0.1rem 0.3rem;
@@ -23,7 +25,7 @@
23
25
  overflow: hidden;
24
26
  }
25
27
 
26
- @mixin preview_pre_codeblock {
28
+ @mixin preview_tiptap_pre_codeblock {
27
29
  display: inline-block;
28
30
  width: 100%;
29
31
  vertical-align: top;
@@ -44,7 +46,7 @@
44
46
  }
45
47
  }
46
48
 
47
- @mixin preview_a {
49
+ @mixin preview_tiptap_a {
48
50
  color: $primary;
49
51
  border-bottom: 1px solid $primary;
50
52
  &:hover {
@@ -53,7 +55,7 @@
53
55
  }
54
56
  }
55
57
 
56
- @mixin preview_blockquote {
58
+ @mixin preview_tiptap_blockquote {
57
59
  font-size: $font_larger;
58
60
  padding: $space_sm $space_md;
59
61
  font-style: italic;
@@ -63,7 +65,7 @@
63
65
  }
64
66
  }
65
67
 
66
- @mixin preview_h1 {
68
+ @mixin preview_tiptap_h1 {
67
69
  font-size: $text_largest;
68
70
  line-height: $text_larger;
69
71
  font-weight: $bolder;
@@ -71,7 +73,7 @@
71
73
  margin: 2.1rem 0 0 0;
72
74
  }
73
75
 
74
- @mixin preview_h2 {
76
+ @mixin preview_tiptap_h2 {
75
77
  font-size: $text_larger;
76
78
  line-height: $text_larger;
77
79
  font-weight: $bolder;
@@ -79,7 +81,7 @@
79
81
  margin: 1.9rem 0 0 0;
80
82
  }
81
83
 
82
- @mixin preview_h3 {
84
+ @mixin preview_tiptap_h3 {
83
85
  font-size: $text_large;
84
86
  line-height: $text_large;
85
87
  font-weight: $bolder;
@@ -87,7 +89,7 @@
87
89
  margin: 1.7rem 0 0 0;
88
90
  }
89
91
 
90
- @mixin preview_smaller_headings {
92
+ @mixin preview_tiptap_smaller_headings {
91
93
  font-size: $text_base;
92
94
  line-height: $text_base;
93
95
  letter-spacing: $lspace_tight;
@@ -95,7 +97,7 @@
95
97
  margin: 1rem 0 0 0;
96
98
  }
97
99
 
98
- @mixin preview_hr {
100
+ @mixin preview_tiptap_hr {
99
101
  margin: 2.2rem 0;
100
102
  box-sizing: content-box;
101
103
  overflow: hidden;
@@ -107,7 +109,7 @@
107
109
  border: 0;
108
110
  }
109
111
 
110
- @mixin preview_ol {
112
+ @mixin preview_tiptap_ol {
111
113
  margin: 1rem 0 0 0;
112
114
  padding-left: $space_md;
113
115
  list-style: decimal;
@@ -119,7 +121,7 @@
119
121
  }
120
122
  }
121
123
 
122
- @mixin preview_ul {
124
+ @mixin preview_tiptap_ul {
123
125
  list-style-position: disc;
124
126
  margin: 1rem 0 0 0;
125
127
  padding-left: $space_md;
@@ -130,3 +132,37 @@
130
132
  }
131
133
  }
132
134
  }
135
+
136
+ // Trix mixins section (Rails and React default editor)
137
+ @mixin preview_trix_div {
138
+ line-height: 1.4;
139
+ }
140
+
141
+ @mixin preview_trix_h1 {
142
+ font-size: 2em;
143
+ line-height: 1.4;
144
+ }
145
+ @mixin preview_trix_blockquote {
146
+ border: 0 solid #ccc;
147
+ border-left-width: 0.3em;
148
+ margin-left: 0.3em;
149
+ padding-left: 0.6em;
150
+ line-height: 1.4;
151
+ }
152
+
153
+ @mixin preview_trix_li {
154
+ line-height: 1.4;
155
+ margin-left: $space_sm;
156
+ }
157
+
158
+ @mixin preview_trix_pre {
159
+ display: inline-block;
160
+ width: 100%;
161
+ vertical-align: top;
162
+ font-family: monospace;
163
+ font-size: 0.9em;
164
+ padding: 0.5em;
165
+ white-space: pre;
166
+ background-color: #eee;
167
+ overflow-x: auto;
168
+ }
@@ -10,18 +10,6 @@
10
10
  @import "./trix_styles";
11
11
  @import "./tiptap_styles";
12
12
 
13
- .trix-content pre {
14
- display: inline-block;
15
- width: 100%;
16
- vertical-align: top;
17
- font-family: monospace;
18
- font-size: 0.9em;
19
- padding: 0.5em;
20
- white-space: pre;
21
- background-color: #ccc !important;
22
- color: black !important;
23
- overflow-x: auto;
24
- }
25
13
  [class^=pb_rich_text_editor_kit] {
26
14
  // Disables File Attatchment Button in Toolbar
27
15
  trix-toolbar [data-trix-button-group="file-tools"] {
@@ -86,44 +86,44 @@
86
86
  }
87
87
 
88
88
  code {
89
- @include preview_code;
89
+ @include preview_tiptap_code;
90
90
  }
91
91
 
92
92
  pre {
93
- @include preview_pre_codeblock;
93
+ @include preview_tiptap_pre_codeblock;
94
94
  }
95
95
  a {
96
- @include preview_a;
96
+ @include preview_tiptap_a;
97
97
  }
98
98
  blockquote {
99
- @include preview_blockquote;
99
+ @include preview_tiptap_blockquote;
100
100
  }
101
101
  &:focus-visible {
102
102
  outline: unset;
103
103
  @include transition_default;
104
104
  }
105
105
  h1 {
106
- @include preview_h1;
106
+ @include preview_tiptap_h1;
107
107
  }
108
108
  h2 {
109
- @include preview_h2;
109
+ @include preview_tiptap_h2;
110
110
  }
111
111
  h3 {
112
- @include preview_h3;
112
+ @include preview_tiptap_h3;
113
113
  }
114
114
  h4,
115
115
  h5,
116
116
  h6 {
117
- @include preview_smaller_headings;
117
+ @include preview_tiptap_smaller_headings;
118
118
  }
119
119
  hr {
120
- @include preview_hr;
120
+ @include preview_tiptap_hr;
121
121
  }
122
122
  ol {
123
- @include preview_ol;
123
+ @include preview_tiptap_ol;
124
124
  }
125
125
  ul {
126
- @include preview_ul;
126
+ @include preview_tiptap_ul;
127
127
  }
128
128
  }
129
129
  }
@@ -170,40 +170,40 @@
170
170
  }
171
171
  }
172
172
  .tiptap-content {
173
- @include preview_first_child;
173
+ @include preview_tiptap_first_child;
174
174
  a {
175
- @include preview_a;
175
+ @include preview_tiptap_a;
176
176
  }
177
177
  blockquote {
178
- @include preview_blockquote;
178
+ @include preview_tiptap_blockquote;
179
179
  }
180
180
  h1 {
181
- @include preview_h1;
181
+ @include preview_tiptap_h1;
182
182
  }
183
183
  h2 {
184
- @include preview_h2;
184
+ @include preview_tiptap_h2;
185
185
  }
186
186
  h3 {
187
- @include preview_h3;
187
+ @include preview_tiptap_h3;
188
188
  }
189
189
  h4,
190
190
  h5,
191
191
  h6 {
192
- @include preview_smaller_headings;
192
+ @include preview_tiptap_smaller_headings;
193
193
  }
194
194
  hr {
195
- @include preview_hr;
195
+ @include preview_tiptap_hr;
196
196
  }
197
197
  ol {
198
- @include preview_ol;
198
+ @include preview_tiptap_ol;
199
199
  }
200
200
  p {
201
- @include preview_p;
201
+ @include preview_tiptap_p;
202
202
  }
203
203
  pre {
204
- @include preview_pre_codeblock;
204
+ @include preview_tiptap_pre_codeblock;
205
205
  }
206
206
  ul {
207
- @include preview_ul;
207
+ @include preview_tiptap_ul;
208
208
  }
209
209
  }
@@ -1,3 +1,5 @@
1
+ @import "previewer_mixin";
2
+
1
3
  @charset "UTF-8";
2
4
  /*
3
5
  Trix 1.3.0
@@ -297,41 +299,31 @@ trix-editor .attachment__metadata {
297
299
  trix-editor .attachment__metadata .attachment__size {
298
300
  margin-left: 0.2em;
299
301
  white-space: nowrap; }
302
+ trix-editor blockquote {
303
+ @include preview_trix_blockquote; }
304
+ trix-editor [dir=rtl] blockquote,
305
+ trix-editor blockquote[dir=rtl] {
306
+ @include preview_trix_blockquote }
300
307
  @charset "UTF-8";
301
- .trix-content {
302
- line-height: 1.5; }
303
- .trix-content * {
304
- box-sizing: border-box;
305
- margin: 0;
306
- padding: 0; }
308
+ .trix-content * {
309
+ box-sizing: border-box;
310
+ margin: 0;
311
+ padding: 0; }
312
+ .trix-content#content-preview div {
313
+ @include preview_trix_div; }
307
314
  .trix-content h1 {
308
- font-size: 1.2em;
309
- line-height: 1.2; }
315
+ @include preview_trix_h1; }
310
316
  .trix-content blockquote {
311
- border: 0 solid #ccc;
312
- border-left-width: 0.3em;
313
- margin-left: 0.3em;
314
- padding-left: 0.6em; }
317
+ @include preview_trix_blockquote; }
315
318
  .trix-content [dir=rtl] blockquote,
316
319
  .trix-content blockquote[dir=rtl] {
317
- border-width: 0;
318
- border-right-width: 0.3em;
319
- margin-right: 0.3em;
320
- padding-right: 0.6em; }
320
+ @include preview_trix_blockquote; }
321
321
  .trix-content li {
322
- margin-left: 1em; }
322
+ @include preview_trix_li; }
323
323
  .trix-content [dir=rtl] li {
324
- margin-right: 1em; }
324
+ @include preview_trix_li; }
325
325
  .trix-content pre {
326
- display: inline-block;
327
- width: 100%;
328
- vertical-align: top;
329
- font-family: monospace;
330
- font-size: 0.9em;
331
- padding: 0.5em;
332
- white-space: pre;
333
- background-color: #eee;
334
- overflow-x: auto; }
326
+ @include preview_trix_pre; }
335
327
  .trix-content img {
336
328
  max-width: 100%;
337
329
  height: auto; }
@@ -1,7 +1,7 @@
1
1
 
2
2
  <%= pb_rails("rich_text_editor", props: { id: "content-preview-editor" }) %>
3
3
  <div id="card-obfuscation" style="display:none">
4
- <%= pb_rails("card", props: { margin_top: "md" }) do %>
4
+ <%= pb_rails("card", props: { margin_top: "md", max_width: "md", padding: "sm" }) do %>
5
5
  <div id="content-preview" class="trix-content">
6
6
  </div>
7
7
  <% end %>
@@ -11,15 +11,25 @@
11
11
  <% end %>
12
12
 
13
13
  <script>
14
- // Button event handler
15
- const button = document.getElementById('preview-button');
16
- button.addEventListener('click', function() {
17
- const content = document.getElementById('content-preview-editor');
18
- const previewArea = document.getElementById('content-preview');
19
- const cardDiv = document.getElementById('card-obfuscation');
14
+ document.addEventListener('DOMContentLoaded', () => {
15
+ function handleButtonClick() {
16
+ const editorContainer = [...document.querySelectorAll('[data-react-props]')]
17
+ .find(element => element.getAttribute('data-react-props')?.includes('"id":"content-preview-editor"'))
20
18
 
21
- previewArea.innerHTML = content.value;
22
- cardDiv.classList.add('mt_md');
23
- cardDiv.style.display = 'block';
24
- });
19
+ const editorElement = editorContainer?.querySelector('trix-editor')
20
+ const inputId = editorElement?.getAttribute('input')
21
+ const inputElement = inputId && document.getElementById(inputId)
22
+
23
+ const editorContent = inputElement?.value || ''
24
+ const previewArea = document.getElementById('content-preview')
25
+ const cardDiv = document.getElementById('card-obfuscation')
26
+
27
+ if (previewArea && cardDiv) {
28
+ previewArea.innerHTML = editorContent
29
+ cardDiv.style.display = 'block'
30
+ }
31
+ }
32
+
33
+ document.getElementById('preview-button')?.addEventListener('click', handleButtonClick)
34
+ })
25
35
  </script>
@@ -8,7 +8,7 @@
8
8
  <br>
9
9
 
10
10
  <%= pb_rails("timestamp", props: {
11
- timestamp: DateTime.now - 3.months,
11
+ timestamp: DateTime.now,
12
12
  variant: "elapsed",
13
13
  show_user: false
14
14
  }) %>
@@ -16,7 +16,7 @@
16
16
  <br>
17
17
 
18
18
  <%= pb_rails("timestamp", props: {
19
- timestamp: DateTime.now - 320.days,
19
+ timestamp: DateTime.now,
20
20
  variant: "elapsed",
21
21
  show_user: false,
22
22
  hide_updated: true
@@ -27,18 +27,6 @@ module Playbook
27
27
  values: %w[default elapsed updated],
28
28
  default: "default"
29
29
 
30
- # Variables to use with pb_time_ago method
31
- SECS_FORTY_FIVE = 45
32
- SECS_PER_MIN = 60
33
- SECS_PER_HOUR = 60 * SECS_PER_MIN # 3,600 seconds
34
- SECS_PER_DAY = 24 * SECS_PER_HOUR # 86,400 seconds
35
- SECS_PER_WEEK = 7 * SECS_PER_DAY # 604,800 seconds
36
- SECS_PER_26 = 26 * SECS_PER_DAY # 26 days = 2,246,400 seconds
37
- SECS_PER_MONTH = 4 * SECS_PER_WEEK # 2,419,200 seconds
38
- SECS_PER_YEAR = 12 * SECS_PER_MONTH # 29,030,400 seconds
39
- SECS_PER_320 = 320 * SECS_PER_DAY # 320 days = 27,648,000 seconds
40
- SECS_PER_CENT = 100 * SECS_PER_YEAR # 3,153,600,000 seconds
41
-
42
30
  def classname
43
31
  generate_classname("pb_timestamp_kit", variant_class, align)
44
32
  end
@@ -85,42 +73,10 @@ module Playbook
85
73
 
86
74
  def format_elapsed_string
87
75
  user_string = show_user ? " by #{text}" : ""
88
- datetime_string = " #{pb_time_ago(pb_date_time.convert_to_timestamp)} ago"
89
- datetime_string[1] = hide_updated ? datetime_string[1].upcase : datetime_string[1]
76
+ datetime_string = " #{time_ago_in_words(pb_date_time.convert_to_timestamp)} ago"
90
77
  updated_string = hide_updated ? "" : "Last updated"
91
- "#{updated_string}#{user_string}#{datetime_string}"
92
- end
93
78
 
94
- def pb_time_ago(value)
95
- time_ago = DateTime.now.to_i - value.to_i
96
- case time_ago
97
- when (0...SECS_FORTY_FIVE)
98
- "a few seconds"
99
- when (SECS_FORTY_FIVE...SECS_PER_MIN)
100
- "a minute"
101
- when (SECS_PER_MIN...SECS_PER_HOUR)
102
- time = time_ago / SECS_PER_MIN
103
- time == 1 ? "a minute" : "#{time_ago / SECS_PER_MIN} minutes"
104
- when (SECS_PER_HOUR...SECS_PER_DAY)
105
- time = time_ago / SECS_PER_HOUR
106
- time == 1 ? "an hour" : "#{time_ago / SECS_PER_HOUR} hours"
107
- when (SECS_PER_DAY...SECS_PER_WEEK)
108
- time = time_ago / SECS_PER_DAY
109
- time == 1 ? "a day" : "#{time_ago / SECS_PER_DAY} days"
110
- when (SECS_PER_WEEK...SECS_PER_26)
111
- time = time_ago / SECS_PER_WEEK
112
- time == 1 ? "a week" : "#{time_ago / SECS_PER_WEEK} weeks"
113
- when (SECS_PER_26...SECS_PER_MONTH)
114
- "a month"
115
- when (SECS_PER_MONTH...SECS_PER_320)
116
- time = time_ago / SECS_PER_MONTH
117
- time == 1 ? "a month" : "#{time_ago / SECS_PER_MONTH} months"
118
- when (SECS_PER_320...SECS_PER_YEAR)
119
- "a year"
120
- when (SECS_PER_YEAR...SECS_PER_CENT)
121
- time = time_ago / SECS_PER_YEAR
122
- time == 1 ? "a year" : "#{time_ago / SECS_PER_YEAR} years"
123
- end
79
+ "#{updated_string}#{user_string}#{datetime_string}"
124
80
  end
125
81
 
126
82
  def datetime_or_text