playbook_ui 14.1.0.pre.alpha.PA1477timestampkit3536 → 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.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +2 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +3 -3
  4. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -1
  5. data/app/pb_kits/playbook/pb_badge/_badge.scss +9 -0
  6. data/app/pb_kits/playbook/pb_badge/_badge.tsx +8 -3
  7. data/app/pb_kits/playbook/pb_badge/badge.rb +1 -1
  8. data/app/pb_kits/playbook/pb_badge/badge.test.js +17 -11
  9. data/app/pb_kits/playbook/pb_badge/docs/_badge_notification.html.erb +13 -0
  10. data/app/pb_kits/playbook/pb_badge/docs/_badge_notification.jsx +31 -12
  11. data/app/pb_kits/playbook/pb_button/_button.tsx +4 -1
  12. data/app/pb_kits/playbook/pb_button/button.html.erb +1 -1
  13. data/app/pb_kits/playbook/pb_button/button.rb +4 -0
  14. data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +2 -2
  15. data/app/pb_kits/playbook/pb_dialog/_close_icon.tsx +5 -1
  16. data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +3 -1
  17. data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +20 -1
  18. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +1 -1
  19. data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +4 -0
  20. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +1 -5
  21. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.jsx +46 -0
  22. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +1 -0
  23. data/app/pb_kits/playbook/pb_dialog/docs/index.js +1 -0
  24. data/app/pb_kits/playbook/pb_filter/filter.rb +1 -1
  25. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -0
  26. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +43 -25
  27. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +6 -2
  28. data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -2
  29. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +4 -4
  30. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +4 -0
  31. data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.scss +3 -0
  32. data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.tsx +72 -0
  33. data/app/pb_kits/playbook/pb_gantt_chart/docs/_gantt_chart_default.jsx +53 -0
  34. data/app/pb_kits/playbook/pb_gantt_chart/docs/example.yml +7 -0
  35. data/app/pb_kits/playbook/pb_gantt_chart/docs/index.js +1 -0
  36. data/app/pb_kits/playbook/pb_gantt_chart/gantt_chart.test.jsx +19 -0
  37. data/app/pb_kits/playbook/pb_icon/_icon.tsx +1 -1
  38. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +0 -2
  39. data/app/pb_kits/playbook/pb_pagination/_pagination.scss +49 -13
  40. data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +164 -0
  41. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default.jsx +19 -0
  42. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default_react.md +1 -0
  43. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx +62 -0
  44. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change_react.md +1 -0
  45. data/app/pb_kits/playbook/pb_pagination/docs/data.js +23 -0
  46. data/app/pb_kits/playbook/pb_pagination/docs/example.yml +3 -1
  47. data/app/pb_kits/playbook/pb_pagination/docs/index.js +2 -0
  48. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +0 -7
  49. data/app/pb_kits/playbook/pb_popover/_popover.tsx +10 -5
  50. data/app/pb_kits/playbook/pb_rich_text_editor/_previewer_mixin.scss +168 -0
  51. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +0 -12
  52. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +50 -76
  53. data/app/pb_kits/playbook/pb_rich_text_editor/_trix_styles.scss +19 -27
  54. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_preview.jsx +73 -0
  55. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.html.erb +21 -11
  56. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
  57. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -1
  58. data/app/pb_kits/playbook/pb_star_rating/index.js +78 -41
  59. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +4 -2
  60. data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +17 -0
  61. data/app/pb_kits/playbook/pb_star_rating/subcomponents/_star_rating_display.tsx +0 -2
  62. data/app/pb_kits/playbook/pb_star_rating/subcomponents/_star_rating_interactive.tsx +0 -1
  63. data/app/pb_kits/playbook/pb_time/_time.tsx +12 -8
  64. data/app/pb_kits/playbook/pb_time/time.html.erb +3 -3
  65. data/app/pb_kits/playbook/pb_time/time.rb +4 -0
  66. data/app/pb_kits/playbook/pb_timestamp/timestamp.rb +2 -37
  67. data/app/pb_kits/playbook/tokens/_container.scss +21 -0
  68. data/app/pb_kits/playbook/utilities/_min_width.scss +45 -0
  69. data/app/pb_kits/playbook/utilities/globalPropNames.mjs +1 -0
  70. data/app/pb_kits/playbook/utilities/globalProps.ts +20 -3
  71. data/app/pb_kits/playbook/utilities/icons/allicons.tsx +59 -0
  72. data/app/pb_kits/playbook/utilities/icons/clock.svg +9 -0
  73. data/app/pb_kits/playbook/utilities/icons/spinner.svg +3 -0
  74. data/app/pb_kits/playbook/utilities/icons/times.svg +3 -0
  75. data/dist/chunks/_typeahead-Cq7RLPBA.js +22 -0
  76. data/dist/chunks/_weekday_stacked-Cykj5kLZ.js +45 -0
  77. data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
  78. data/dist/chunks/{lib-BE0Z3F7x.js → lib-DErGXNy3.js} +2 -2
  79. data/dist/chunks/{pb_form_validation-TzZQ0Flx.js → pb_form_validation-BC6kh7Hu.js} +1 -1
  80. data/dist/chunks/vendor.js +1 -1
  81. data/dist/menu.yml +4 -0
  82. data/dist/playbook-doc.js +1 -1
  83. data/dist/playbook-rails-react-bindings.js +1 -1
  84. data/dist/playbook-rails.js +1 -1
  85. data/dist/playbook.css +1 -1
  86. data/lib/playbook/classnames.rb +1 -0
  87. data/lib/playbook/spacing.rb +31 -2
  88. data/lib/playbook/version.rb +1 -1
  89. metadata +32 -10
  90. data/dist/chunks/_typeahead-D-4y9pbv.js +0 -22
  91. data/dist/chunks/_weekday_stacked-Cax4nrUa.js +0 -45
  92. data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
  93. /data/app/pb_kits/playbook/pb_pagination/docs/{_pagination_default.md → _pagination_default_rails.md} +0 -0
@@ -3,4 +3,6 @@ examples:
3
3
  rails:
4
4
  - pagination_default: Default
5
5
 
6
-
6
+ react:
7
+ - pagination_default: Default
8
+ - pagination_page_change: Page Change
@@ -0,0 +1,2 @@
1
+ export { default as PaginationDefault } from './_pagination_default.jsx'
2
+ export { default as PaginationPageChange } from './_pagination_page_change.jsx'
@@ -60,7 +60,6 @@ $flag-min-resolution: 192dpi;
60
60
  }
61
61
 
62
62
  .iti__flag {
63
- background-image: url("https://intl-tel-input.com/intl-tel-input/img/flags.png");
64
63
  border-radius: 1px;
65
64
  }
66
65
 
@@ -197,10 +196,4 @@ $flag-min-resolution: 192dpi;
197
196
  }
198
197
  }
199
198
  }
200
-
201
- @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: $flag-min-resolution) {
202
- .iti__flag {
203
- background-image: url("https://intl-tel-input.com/intl-tel-input/img/flags.png");
204
- }
205
- }
206
199
  }
@@ -21,6 +21,8 @@ import classnames from "classnames";
21
21
  import { globalProps, GlobalProps } from "../utilities/globalProps";
22
22
  import { uniqueId } from 'lodash';
23
23
 
24
+ type ModifiedGlobalProps = Omit<GlobalProps, 'minWidth'>
25
+
24
26
  type PbPopoverProps = {
25
27
  aria?: { [key: string]: string };
26
28
  className?: string;
@@ -32,7 +34,7 @@ type PbPopoverProps = {
32
34
  reference: PopperReference & any;
33
35
  show?: boolean;
34
36
  shouldClosePopover?: (arg0: boolean) => void;
35
- } & GlobalProps & Omit<PopperProps<any>, 'children'>
37
+ } & ModifiedGlobalProps & Omit<PopperProps<any>, 'children'>
36
38
  & { children?: React.ReactChild[] | React.ReactChild }
37
39
 
38
40
  // Prop enabled default modifiers here
@@ -80,10 +82,13 @@ const Popover = (props: PbPopoverProps) => {
80
82
  targetId,
81
83
  } = props;
82
84
 
85
+ const items = globalProps(props).split(' ')
86
+ const filteredItems = items.filter(item => !item.includes('min_width'))
87
+ const filteredGlobalProps = filteredItems.join(' ')
83
88
  const popoverSpacing =
84
- globalProps(props).includes("dark") || !globalProps(props)
89
+ filteredGlobalProps.includes("dark") || !filteredGlobalProps
85
90
  ? "p_sm"
86
- : globalProps(props);
91
+ : filteredGlobalProps
87
92
  const overflowHandling = maxHeight || maxWidth ? "overflow_handling" : "";
88
93
  const zIndexStyle = zIndex ? { zIndex: zIndex } : {};
89
94
  const widthHeightStyles = () => {
@@ -100,7 +105,7 @@ const Popover = (props: PbPopoverProps) => {
100
105
  const htmlProps = buildHtmlProps(htmlOptions);
101
106
  const classes = classnames(
102
107
  buildCss("pb_popover_kit"),
103
- globalProps(props),
108
+ filteredGlobalProps,
104
109
  className
105
110
  );
106
111
 
@@ -250,4 +255,4 @@ const PbReactPopover = (props: PbPopoverProps): React.ReactElement => {
250
255
  );
251
256
  };
252
257
 
253
- export default PbReactPopover;
258
+ export default PbReactPopover;
@@ -0,0 +1,168 @@
1
+ @import "../tokens/border_radius";
2
+ @import "../tokens/colors";
3
+ @import "../tokens/spacing";
4
+ @import "../tokens/typography";
5
+
6
+
7
+ // Tiptap mixins section (React Advanced Editor)
8
+ @mixin preview_tiptap_first_child {
9
+ :first-child {
10
+ margin-top: 0;
11
+ }
12
+ }
13
+
14
+ @mixin preview_tiptap_p {
15
+ margin: 1rem 0 0 0;
16
+ min-height: 1rem;
17
+ }
18
+
19
+ @mixin preview_tiptap_code {
20
+ font-family: monospace;
21
+ background: $bg_light;
22
+ padding: 0.1rem 0.3rem;
23
+ box-shadow: 0 2px 10px $shadow;
24
+ border-radius: 0.25rem;
25
+ overflow: hidden;
26
+ }
27
+
28
+ @mixin preview_tiptap_pre_codeblock {
29
+ display: inline-block;
30
+ width: 100%;
31
+ vertical-align: top;
32
+ font-family: monospace;
33
+ font-size: 0.9em;
34
+ padding: 0.5em;
35
+ overflow-x: auto;
36
+ background: $bg_dark;
37
+ padding: $space_sm;
38
+ border-radius: $border_rad_heaviest;
39
+ margin: 1.5rem 0 2rem 0;
40
+
41
+ code {
42
+ background: transparent !important;
43
+ box-shadow: none;
44
+ border: 0;
45
+ color: #faf6e4;
46
+ }
47
+ }
48
+
49
+ @mixin preview_tiptap_a {
50
+ color: $primary;
51
+ border-bottom: 1px solid $primary;
52
+ &:hover {
53
+ color: $text_lt_default;
54
+ border-bottom: 1px solid $text_lt_default;
55
+ }
56
+ }
57
+
58
+ @mixin preview_tiptap_blockquote {
59
+ font-size: $font_larger;
60
+ padding: $space_sm $space_md;
61
+ font-style: italic;
62
+ margin: 1rem 0 0 0;
63
+ p {
64
+ margin: 0;
65
+ }
66
+ }
67
+
68
+ @mixin preview_tiptap_h1 {
69
+ font-size: $text_largest;
70
+ line-height: $text_larger;
71
+ font-weight: $bolder;
72
+ letter-spacing: $lspace_tight;
73
+ margin: 2.1rem 0 0 0;
74
+ }
75
+
76
+ @mixin preview_tiptap_h2 {
77
+ font-size: $text_larger;
78
+ line-height: $text_larger;
79
+ font-weight: $bolder;
80
+ letter-spacing: $lspace_tight;
81
+ margin: 1.9rem 0 0 0;
82
+ }
83
+
84
+ @mixin preview_tiptap_h3 {
85
+ font-size: $text_large;
86
+ line-height: $text_large;
87
+ font-weight: $bolder;
88
+ letter-spacing: $lspace_tight;
89
+ margin: 1.7rem 0 0 0;
90
+ }
91
+
92
+ @mixin preview_tiptap_smaller_headings {
93
+ font-size: $text_base;
94
+ line-height: $text_base;
95
+ letter-spacing: $lspace_tight;
96
+ font-weight: $bolder;
97
+ margin: 1rem 0 0 0;
98
+ }
99
+
100
+ @mixin preview_tiptap_hr {
101
+ margin: 2.2rem 0;
102
+ box-sizing: content-box;
103
+ overflow: hidden;
104
+ background: transparent;
105
+ border-bottom: 1px solid $transparent;
106
+ height: 1px;
107
+ padding: 0;
108
+ background-color: $border_light;
109
+ border: 0;
110
+ }
111
+
112
+ @mixin preview_tiptap_ol {
113
+ margin: 1rem 0 0 0;
114
+ padding-left: $space_md;
115
+ list-style: decimal;
116
+ li {
117
+ margin: 2px 0;
118
+ p {
119
+ margin: 0;
120
+ }
121
+ }
122
+ }
123
+
124
+ @mixin preview_tiptap_ul {
125
+ list-style-position: disc;
126
+ margin: 1rem 0 0 0;
127
+ padding-left: $space_md;
128
+ li {
129
+ margin: 2px 0;
130
+ p {
131
+ margin: 0;
132
+ }
133
+ }
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"] {
@@ -6,6 +6,7 @@
6
6
  @import "../tokens/typography";
7
7
  @import "../tokens/shadows";
8
8
  @import "../tokens/transition";
9
+ @import "previewer_mixin";
9
10
 
10
11
  [class^="pb_rich_text_editor_kit"] {
11
12
  .toolbar_button {
@@ -85,109 +86,44 @@
85
86
  }
86
87
 
87
88
  code {
88
- font-family: monospace;
89
- background: $bg_light;
90
- padding: 0.1rem 0.3rem;
91
- margin: 0 5px;
92
- box-shadow: 0 2px 10px $shadow;
93
- border-radius: 0.25rem;
94
- overflow: hidden;
95
- font-size: ($text_small - 1px);
89
+ @include preview_tiptap_code;
96
90
  }
97
91
 
98
92
  pre {
99
- background: $bg_dark;
100
- padding: $space_sm;
101
- border-radius: $border_rad_heaviest;
102
- margin: 1.5rem 0 2rem 0;
103
- code {
104
- background: transparent;
105
- box-shadow: none;
106
- border: 0;
107
- color: #faf6e4;
108
- }
93
+ @include preview_tiptap_pre_codeblock;
109
94
  }
110
95
  a {
111
- color: $primary;
112
- border-bottom: 1px solid $primary;
113
- &:hover {
114
- color: $text_lt_default;
115
- border-bottom: 1px solid $text_lt_default;
116
- }
96
+ @include preview_tiptap_a;
117
97
  }
118
98
  blockquote {
119
- font-size: $font_larger;
120
- padding: $space_sm $space_md;
121
- font-style: italic;
122
- p {
123
- margin: 0;
124
- }
99
+ @include preview_tiptap_blockquote;
125
100
  }
126
101
  &:focus-visible {
127
102
  outline: unset;
128
103
  @include transition_default;
129
104
  }
130
105
  h1 {
131
- font-size: $text_largest;
132
- line-height: $text_larger;
133
- font-weight: $bolder;
134
- letter-spacing: $lspace_tight;
135
- margin: 2.1rem 0 0 0;
106
+ @include preview_tiptap_h1;
136
107
  }
137
108
  h2 {
138
- font-size: $text_larger;
139
- line-height: $text_larger;
140
- font-weight: $bolder;
141
- letter-spacing: $lspace_tight;
142
- margin: 1.9rem 0 0 0;
109
+ @include preview_tiptap_h2;
143
110
  }
144
111
  h3 {
145
- font-size: $text_large;
146
- line-height: $text_large;
147
- font-weight: $bolder;
148
- letter-spacing: $lspace_tight;
149
- margin: 1.7rem 0 0 0;
112
+ @include preview_tiptap_h3;
150
113
  }
151
114
  h4,
152
115
  h5,
153
116
  h6 {
154
- font-size: $text_base;
155
- line-height: $text_base;
156
- letter-spacing: $lspace_tight;
157
- font-weight: $bolder;
117
+ @include preview_tiptap_smaller_headings;
158
118
  }
159
119
  hr {
160
- margin: 2.2rem 0;
161
- box-sizing: content-box;
162
- overflow: hidden;
163
- background: transparent;
164
- border-bottom: 1px solid $transparent;
165
- height: 1px;
166
- padding: 0;
167
- background-color: $border_light;
168
- border: 0;
120
+ @include preview_tiptap_hr;
169
121
  }
170
122
  ol {
171
- margin: 1rem 0 0 0;
172
- padding-left: $space_md;
173
- list-style: decimal;
174
- li {
175
- margin: 2px 0;
176
- p {
177
- margin: 0;
178
- }
179
- }
123
+ @include preview_tiptap_ol;
180
124
  }
181
125
  ul {
182
- list-style-position: disc;
183
- margin: 1rem 0 0 0;
184
- padding-left: $space_md;
185
- li {
186
- margin: 2px 0;
187
- p {
188
- margin: 0;
189
- }
190
- }
126
+ @include preview_tiptap_ul;
191
127
  }
192
128
  }
193
129
  }
@@ -233,3 +169,41 @@
233
169
  }
234
170
  }
235
171
  }
172
+ .tiptap-content {
173
+ @include preview_tiptap_first_child;
174
+ a {
175
+ @include preview_tiptap_a;
176
+ }
177
+ blockquote {
178
+ @include preview_tiptap_blockquote;
179
+ }
180
+ h1 {
181
+ @include preview_tiptap_h1;
182
+ }
183
+ h2 {
184
+ @include preview_tiptap_h2;
185
+ }
186
+ h3 {
187
+ @include preview_tiptap_h3;
188
+ }
189
+ h4,
190
+ h5,
191
+ h6 {
192
+ @include preview_tiptap_smaller_headings;
193
+ }
194
+ hr {
195
+ @include preview_tiptap_hr;
196
+ }
197
+ ol {
198
+ @include preview_tiptap_ol;
199
+ }
200
+ p {
201
+ @include preview_tiptap_p;
202
+ }
203
+ pre {
204
+ @include preview_tiptap_pre_codeblock;
205
+ }
206
+ ul {
207
+ @include preview_tiptap_ul;
208
+ }
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; }
@@ -0,0 +1,73 @@
1
+ import React, { useState } from 'react'
2
+ import { Button, Card, RichTextEditor } from 'playbook-ui'
3
+ import { useEditor, EditorContent } from "@tiptap/react"
4
+ import StarterKit from "@tiptap/starter-kit"
5
+ import Link from '@tiptap/extension-link'
6
+
7
+
8
+ const RichTextEditorAdvancedPreview = (props) => {
9
+
10
+ const editor = useEditor({
11
+ extensions: [
12
+ StarterKit,
13
+ Link
14
+ ],
15
+ content: "Add text here, format it, and press \"Preview Output\" to see what your stylized output will look like on the page."
16
+ })
17
+
18
+ const [showPreview, setShowPreview] = useState(false)
19
+ const [previewText, setPreviewText] = useState(<div />)
20
+
21
+ const handleChange = () => {
22
+ if (editor) {
23
+ setPreviewText(editor.getHTML())
24
+ }
25
+ }
26
+
27
+ const handleClick = () => {
28
+ handleChange()
29
+ setShowPreview(true)
30
+ }
31
+ if (!editor) {
32
+ return null
33
+ }
34
+
35
+
36
+ return (
37
+ <div>
38
+ <RichTextEditor
39
+ advancedEditor={editor}
40
+ id="content-advanced-preview-editor"
41
+ onChange={handleChange}
42
+ {...props}
43
+ >
44
+ <EditorContent editor={editor}/>
45
+ </RichTextEditor>
46
+ {showPreview && (
47
+ <Card
48
+ marginTop="md"
49
+ maxWidth="md"
50
+ >
51
+ <div
52
+ className="tiptap-content"
53
+ // eslint-disable-next-line react/no-danger
54
+ dangerouslySetInnerHTML={{ __html: previewText }}
55
+ id="advanced-preview-content"
56
+ />
57
+ </Card>
58
+ )}
59
+ {!showPreview && (
60
+ <div />
61
+ )}
62
+ <Button
63
+ id="preview-button"
64
+ marginTop="md"
65
+ onClick={handleClick}
66
+ text="Preview Output"
67
+ variant="secondary"
68
+ />
69
+ </div>
70
+ )
71
+ }
72
+
73
+ export default RichTextEditorAdvancedPreview
@@ -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>
@@ -24,3 +24,4 @@ examples:
24
24
  - rich_text_editor_toolbar_bottom: Toolbar Bottom
25
25
  - rich_text_editor_inline: Inline
26
26
  - rich_text_editor_preview: Preview
27
+ - rich_text_editor_advanced_preview: Advanced Preview
@@ -9,4 +9,5 @@ export { default as RichTextEditorInline } from './_rich_text_editor_inline.jsx'
9
9
  export { default as RichTextEditorPreview } from './_rich_text_editor_preview.jsx'
10
10
  export { default as RichTextEditorAdvancedDefault } from './_rich_text_editor_advanced_default.jsx'
11
11
  export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
12
- export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
12
+ export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
13
+ export { default as RichTextEditorAdvancedPreview } from './_rich_text_editor_advanced_preview.jsx'